Skip to content

Commit d9cffce

Browse files
committed
Use an iterator instead of a shared global index
1 parent d863f5c commit d9cffce

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

tests/contrib/openai_agents/test_openai.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,25 +72,16 @@
7272
from tests.helpers import new_worker
7373
from tests.helpers.nexus import create_nexus_endpoint, make_nexus_endpoint_name
7474

75-
response_index: int = 0
76-
7775

7876
class StaticTestModel(TestModel):
7977
__test__ = False
8078
responses: list[ModelResponse] = []
8179

82-
def response(self):
83-
global response_index
84-
response = self.responses[response_index]
85-
response_index += 1
86-
return response
87-
8880
def __init__(
8981
self,
9082
) -> None:
91-
global response_index
92-
response_index = 0
93-
super().__init__(self.response)
83+
self._responses = iter(self.responses)
84+
super().__init__(lambda: next(self._responses))
9485

9586

9687
class TestHelloModel(StaticTestModel):

0 commit comments

Comments
 (0)