Skip to content

Commit 635cf19

Browse files
Fix Order-Dependent Assertions in Parallel Tests (#7879)
* Fix signature field order mismatch * WIP update batch test * fix version in metadata (#7877) * Fix order-dependent assertions in parallel tests --------- Co-authored-by: Chen Qian <[email protected]>
1 parent 73cf640 commit 635cf19

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

tests/predict/test_parallel.py

+7-9
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,8 @@ def forward(self, input):
3232

3333
output = MyModule()(dspy.Example(input="test input").with_inputs("input"))
3434

35-
assert output[0].output == "test output 1"
36-
assert output[1].output == "test output 2"
37-
assert output[2].output == "test output 3"
38-
assert output[3].output == "test output 4"
39-
assert output[4].output == "test output 5"
35+
expected_outputs = {f"test output {i}" for i in range(1, 6)}
36+
assert {r.output for r in output} == expected_outputs
4037

4138

4239
def test_batch_module():
@@ -115,10 +112,11 @@ def forward(self, input):
115112

116113
output = MyModule()(dspy.Example(input="test input").with_inputs("input"))
117114

118-
assert output[0].output == "test output 1"
119-
assert output[1].output == "test output 2"
120-
assert output[2][0].output == "test output 3"
121-
assert output[2][1].output == "test output 4"
115+
# For nested structure, check first two outputs and nested outputs separately
116+
assert {output[0].output, output[1].output} <= {f"test output {i}" for i in range(1, 5)}
117+
assert {output[2][0].output, output[2][1].output} <= {f"test output {i}" for i in range(1, 5)}
118+
all_outputs = {output[0].output, output[1].output, output[2][0].output, output[2][1].output}
119+
assert len(all_outputs) == 4
122120

123121

124122
def test_nested_batch_method():

0 commit comments

Comments
 (0)