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

Support for randomly-repeat-last #164

Merged
merged 1 commit into from Mar 1, 2019
Merged

Conversation

yoyoyopcp
Copy link
Contributor

This option enables the test to run with the previously used randomly
seed.

This option enables the test to run with the previously used randomly
seed.
Copy link
Member

@adamchainz adamchainz left a 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!

tests/test_it.py Show resolved Hide resolved
out = ourtestdir.runpytest('--randomly-seed=33')
out.assert_outcomes(passed=1, failed=0)
out.stdout.fnmatch_lines(['Using --randomly-seed=33'])
ourtestdir.makepyfile(
Copy link
Member

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):
Copy link
Member

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!

@yoyoyopcp
Copy link
Contributor Author

Thank you @adamchainz for the super helpful feedback! Glad to be an official contributor to this project!

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.

None yet

2 participants