-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Path to directory with tests from pytest.ini file is not overloaded by value from command line #1607
Comments
addopts per design is always taken into account, thats the very point of it |
But for other options the behavior is different. For example if we add |
There's a difference however:
So it will collect tests twice. The
In this case only Collecting tests twice has been reported before (#1187), but since it is a change from current behavior (with some uses, albeit rare) and nobody felt strongly about it, we didn't actually work on it. But it seems to me more and more people are surprised by this, so I guess this is something we should change, dropping duplicates by default. Finally, I wrote a small plugin, pytest-drop-dup-tests, which drops duplicated tests that you can use for now as a workaround. |
Thanks for the explanation. I'm now fully aware of the problem. Honestly I reported the issue because I couldn't anything about this in the docs. Maybe it would be worth mentioning this in the documentation? If it was well explained then the current behavior could be left. If you would like I could prepare a PR for this. |
Sure, thanks.
I think we should do this only if we decide to not do #1609 after all. We will probably review this next week during the sprint, so no need to work on this now, but thanks for the offer regardless. 😁 I guess we can close this now, unless you have more questions? |
I done. Go ahead and close the issue. Good luck with the upcoming sprint 👍 |
If the
pytest.ini
file has a test directory path set it will always be taken in to account when collecting test file even if a different value has been specified by the user from command line. This can lead to a situation where the same tests will get collected multiple times.Lets imagine we have the following file structure:
pytest.ini
file:regression/test_regression.py
file:If we run py.test without a test directory path like so:
py.test --collectonly
will result in:which is fine, but is you specify a test directory things start to go wrong.
py.test regression --collectonly
will result in:My venv:
The text was updated successfully, but these errors were encountered: