File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change 1+ from mesa .agent import Agent
2+ from mesa .model import Model
3+
4+
5+ def test_agent_removal ():
6+ class TestAgent (Agent ):
7+ pass
8+
9+ model = Model ()
10+ agent = TestAgent (model .next_id (), model )
11+ # Check if the agent is added
12+ assert agent in model .agents [type (agent )]
13+
14+ agent .remove ()
15+ # Check if the agent is removed
16+ assert agent not in model .agents [type (agent )]
Original file line number Diff line number Diff line change 1+ from mesa .agent import Agent
12from mesa .model import Model
23
34
@@ -40,3 +41,13 @@ def test_reset_randomizer(newseed=42):
4041 assert model ._seed == oldseed
4142 model .reset_randomizer (seed = newseed )
4243 assert model ._seed == newseed
44+
45+
46+ def test_agent_types ():
47+ class TestAgent (Agent ):
48+ pass
49+
50+ model = Model ()
51+ test_agent = TestAgent (model .next_id (), model )
52+ assert test_agent in model .agents [type (test_agent )]
53+ assert type (test_agent ) in model .agent_types
You can’t perform that action at this time.
0 commit comments