-
Notifications
You must be signed in to change notification settings - Fork 94
Allow to pass a callable condition to the flaky marker
#299
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
Allow to pass a callable condition to the flaky marker
#299
Conversation
This introduces a condition parameter to the `@pytest.mark.flaky` decorator, allowing for more granular control over when a test is rerun. The condition can be a callable or a string. If it's a callable, it will be passed the exception object from the failed test. The test will be rerun only if the callable returns True. If it's a string, it will be evaluated with the following objects in its global context: os, sys, platform, config, and error (the exception instance). The test will be rerun only if the string evaluates to True. Exceptions raised by a condition callable are now caught and logged as a warning, preventing the test suite from crashing.
icemac
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the code. Could you please add a change log entry referencing the issue or this PR? This would make it perfect for merge and release.
Issue pytest-dev#230 skip-checks: true
a74576b to
848d2fa
Compare
Apologies for the oversight; it has been added. |
|
Thank you for this PR. 😃 |
|
Released in https://pypi.org/project/pytest-rerunfailures/16.0/. |
…est-dev#299)" This reverts commit bd8cb4d.
|
PR got reverted in #304. |
Closes #230