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
Support for randomly-repeat-last #164
Conversation
This option enables the test to run with the previously used randomly seed.
Change the design from #164.
Change the design from #164.
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.
Hey so I went ahead and merged this so you got the GitHub points but have then done a bunch of redesign in #168. First things that were missing were an update to the documentation (please always do this when updating open source projects, or how will other users discover the features you're adding?) and a note in the changelog (again, to help discovery!).
The main thing though was I thought about the design and realized another flag wasn't necessary, since using --randomly-seed=last
was possible. Also some comments below that could help you for next time.
Thank you for your contribution, now released in version 2.1.0!
out = ourtestdir.runpytest('--randomly-seed=33') | ||
out.assert_outcomes(passed=1, failed=0) | ||
out.stdout.fnmatch_lines(['Using --randomly-seed=33']) | ||
ourtestdir.makepyfile( |
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.
makepyfile
doesn't need re-running between runpytest
runs, as the files are left in place
@@ -82,6 +86,15 @@ def _reseed(config, offset=0): | |||
np_random.set_state(np_random_states[seed]) | |||
|
|||
|
|||
def pytest_configure(config): | |||
if config.option.randomly_repeat_last and config.cache.get('last_seed', None): |
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.
To namespace the cache value (since it's all one big key-value store in pytest), I've changed this to randomly_last_seed
- inline with the command-line options all starting with randomly
!
Thank you @adamchainz for the super helpful feedback! Glad to be an official contributor to this project! |
This option enables the test to run with the previously used randomly
seed.