Skip to content

Commit 1a32360

Browse files
Dilraj07quaquel
andauthored
Fix empties assertions and docstring in discrete space tests (mesa#3793)
Complete test_empties_space by asserting empties count after adding and removing agents to discrete spaces. Fix copy-pasted docstring in test_agents_property. Co-authored-by: Jan Kwakkel <j.h.kwakkel@tudelft.nl>
1 parent eed8b2a commit 1a32360

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

tests/discrete_space/test_discrete_space.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,8 +555,17 @@ def test_empties_space():
555555
assert len(grid.empties) == n
556556

557557
model = Model()
558+
agents = []
558559
for i in range(8):
559-
grid._cells[i].add_agent(CellAgent(model))
560+
agent = CellAgent(model)
561+
grid._cells[i].add_agent(agent)
562+
agents.append(agent)
563+
564+
assert len(grid.empties) == n - 8
565+
566+
# Remove an agent and verify empties count updates
567+
grid._cells[0].remove_agent(agents[0])
568+
assert len(grid.empties) == n - 7
560569

561570

562571
def test_cell_missing_exception():
@@ -604,7 +613,7 @@ def test_grid_validate_parameters():
604613

605614

606615
def test_agents_property():
607-
"""Test empties method for Discrete Spaces."""
616+
"""Test agents property for Discrete Spaces."""
608617
n = 10
609618
m = 20
610619
rng = 42

0 commit comments

Comments
 (0)