-
Notifications
You must be signed in to change notification settings - Fork 30
Feature enhancement to allow turning plugin on and off #550
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
Comments
This is hard to do, the plugin acts at different points in pytest's test lifecycle: collecting tests, then running modules, classes, and functions. To force order for specific tests, you can use pytest-order, which even documents usage with pytest-randomly. Try that for your legacy tests? |
Hi @adamchainz thank you for maintaining this plugin and taking the time to respond to my issue. The project I'm using this for is massive, and adding markers to each test is not feasible. From what I can tell, I think the change would need to occur inside https://github.com/pytest-dev/pytest-randomly/blob/main/src/pytest_randomly/__init__.py Let me know what your thoughts are and thanks once again. |
I think your proposal is too niche to include in pytest-randomly right now. If others +1 this issue, maybe. Also, you may be able to achieve what you want with a custom plugin in your project. pytest plugins are very flexible and it should be possible to make one that disables pytest-randomly by default - perhaps by telling pytest to disable the plugin, or perhaps by activating the |
First time using this plugin and my initial thoughts are: I want this to be opt-in rather than opt-out |
Hey @adamchainz any chance you'd reconsider this? I'd be happy to do the pr if you're open to this idea. |
I am not really convinced that we need any new mechanism here for opting in. We already have these:
It doesn't seem necessary to me to introduce another mechanism and to maintain that for a long time. The plugin is only a few hundred lines long with rare changes. If you need extreme customization, you can also copy the relevant parts into your project's |
|
Description
Hello,
Using this plugin occasionally while writing new tests to prevent flakiness, but old tests still need to run without the random order.
Currently accomplishing this via pytest.ini which includes -p no:randomly and a separate one you use via -c pytest-randomly.ini
This feels rather clunky, I'd like to propose creating a pytest command line argument to turn the plugin off as needed
The other option is to create a bash variable PYTEST_USE_RANDOMLY which defaults to true, but can be flipped on and off as you go
I'm more than happy to make this change, but wanted to run it by the community before opening the PR.
The text was updated successfully, but these errors were encountered: