Warn for non-repeatable random tests in a testing environment#384
Merged
jcapriot merged 2 commits intosimpeg:mainfrom Nov 5, 2024
Merged
Warn for non-repeatable random tests in a testing environment#384jcapriot merged 2 commits intosimpeg:mainfrom
jcapriot merged 2 commits intosimpeg:mainfrom
Conversation
This would catch it during test collections as well.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #384 +/- ##
==========================================
+ Coverage 86.17% 86.19% +0.01%
==========================================
Files 90 90
Lines 18576 18603 +27
Branches 2099 2103 +4
==========================================
+ Hits 16008 16034 +26
Misses 1884 1884
- Partials 684 685 +1 ☔ View full report in Codecov by Sentry. |
Member
Author
|
@santisoler Thought this would be a good thing to do. It will only issue a warning when ran in the testing environment. |
Member
|
I like it! Nicely done. |
prisae
added a commit
that referenced
this pull request
Jan 10, 2025
#384 popped up as warning in my tests, where is saw the missing white spaces ("berepeatable" and "isnot"): ``` /home/dtr/Codes/emg3d/tests/test_simulations.py:959: UserWarning: You are running a pytest without setting a random seed, the results might not berepeatable. For repeatable tests please pass an argument to `random seed` that isnot `None`. discretize.tests.assert_isadjoint( ```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When someone runs a test that would randomly initialize a random number generator from
pytestornosetest, issue a warning recommending setting the seed for repeatable tests.This checks by using stack inspection looking for either
_pytest.ornose.