Skip to content

Commit b92b288

Browse files
seanzhougooglecopybara-github
authored andcommitted
chore: fix flaky unit tests: tests/unittests/flows/llm_flows/test_functions_simple.py
original tests assert too strict time boundary, now we only assert the parallel execution time should be less than sequential execution time PiperOrigin-RevId: 800563929
1 parent 8d6f138 commit b92b288

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

tests/unittests/flows/llm_flows/test_functions_simple.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -760,11 +760,13 @@ async def slow_function_2(delay: float = 0.1) -> dict:
760760
start_time_diff < 0.01
761761
), f'Functions started too far apart: {start_time_diff}s'
762762

763-
# Total execution time should be closer to 0.1s (parallel) than 0.2s (sequential)
764-
# Allow some overhead for task creation and synchronization
765-
assert (
766-
total_time < 0.15
767-
), f'Execution took too long: {total_time}s, expected < 0.15s'
763+
# Total execution time should be less than the sum of all parallel function delays (0.2s)
764+
# This proves parallel execution rather than sequential execution
765+
sequential_time = 0.2 # 0.1s + 0.1s if functions ran sequentially
766+
assert total_time < sequential_time, (
767+
f'Execution took too long: {total_time}s, expected < {sequential_time}s'
768+
' (sequential time)'
769+
)
768770

769771
# Verify the results are correct
770772
assert testing_utils.simplify_events(events) == [

0 commit comments

Comments
 (0)