22
33import pytest
44from mesa .agent import Agent , AgentSet
5- from mesa .model import Model
65from mesa .experimental .meta_agents .meta_agent import MetaAgent
6+ from mesa .model import Model
77
88from mesa_llm .parallel_stepping import (
99 disable_automatic_parallel_stepping ,
@@ -100,6 +100,8 @@ async def wrapper():
100100 asyncio .run (wrapper ())
101101 assert a1 .counter == 1
102102 assert a2 .counter == 1
103+
104+
103105@pytest .fixture (autouse = True )
104106def manage_parallel_stepping_patch ():
105107 # Helper to clean up parallel stepping state if tests fail
@@ -109,6 +111,7 @@ def manage_parallel_stepping_patch():
109111
110112# --- Meta Agent Parallel Conflict Tests ---
111113
114+
112115class ConflictWorker (Agent ):
113116 def __init__ (self , model ):
114117 super ().__init__ (model )
@@ -143,10 +146,10 @@ def test_meta_agent_parallel_conflict_fix():
143146 """
144147 enable_automatic_parallel_stepping ("asyncio" )
145148 model = ConflictBusinessModel ()
146-
149+
147150 # Run one step
148151 model .step ()
149-
152+
150153 # Assert worker was only stepped once
151154 # If the fix failed, this would be 2
152155 assert model .worker .step_count == 1
@@ -156,25 +159,25 @@ def test_meta_agent_multithreaded_conflict_fix():
156159 """Test same logic but with multithreaded mode."""
157160 disable_automatic_parallel_stepping ()
158161 enable_automatic_parallel_stepping ("threading" )
159-
162+
160163 model = ConflictBusinessModel ()
161164 model .step ()
162-
165+
163166 assert model .worker .step_count == 1
164167
165168
166169def test_agent_becomes_independent_again ():
167170 """Test that an agent removed from MetaAgent is stepped by scheduler again."""
168171 enable_automatic_parallel_stepping ("asyncio" )
169172 model = ConflictBusinessModel ()
170-
173+
171174 # 1. Initially it's a component
172175 assert model .worker .is_component is True
173-
176+
174177 # 2. Remove it from manager
175178 model .manager .remove_constituting_agents ({model .worker })
176179 assert model .worker .is_component is False
177-
180+
178181 # 3. Model step should now step the worker directly
179182 model .step ()
180183 assert model .worker .step_count == 1
0 commit comments