Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Order-Dependent Flaky Test #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zhihao11ui
Copy link

Noticed flaky test when run: pytest --flake-finder test_iter.py. This fix addresses an Order-Dependent Brittle (OD-Brit) flaky test caused by reusing an exhausted iterator in multiple function calls. The test failed due to the iterator being consumed after its first use, leading to a StopIteration error on subsequent calls.

The fix recreates fresh iterators before passing them to functions (first() and last()) to ensure the iterator isn't exhausted between uses, and conditional handling was added for non-iterable types (like lists and tuples) to allow direct reuse without exhaustion issues.

This ensures that the tests now run consistently without being affected by the state of the iterators.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant