pytest
pytest copied to clipboard
Make use of `-I` in all Python invocations
This helps prevent testing the non-installed source. Additionally, the patch updates the docs to demonstrate a more predictable runpy-style invocation method.
For user documentation, I think we should keep without the
-I, we can't guess what the user wants, for example it will break many of my works projects to use-I. We can perhaps add a note somewhere about it.
@bluetech the docs was my primary motivation originally: I know that a lot of people make this mistake because it's obvious, sometimes. So in the patch, I didn't fully remove the mentions of -m but flipped the default example to behave closer to the way just pytest does — it seems to be more intuitive this way. It does make sense to show just -m in the section that explicitly suggests importing from a neighboring directory, though.
For our test suites, it will break a few things we do in tox.ini, for example setting
PYTHONWARNDEFAULTENCODING=1
Would changing those to -X be acceptable?
I think we shouldn't use -I in the user docs because it isn't really meant for it:
-E - users often set envvars like PYTHONPATH, PYTHONWARNINGS etc, they shouldn't be ignored (and plain pytest doesn't).
-P users sometimes intentionally rely on it, we do intentionally document python -m pytest as a way to achieve that. But I think it's worth adding a note in the docs about python -Pm pytest, in case need to use -m but don't want to sys.path behavior.
-s users may rely on it, it's a reasonable thing to install pytest to user site.
Would changing those to -X be acceptable?
I think the right fix here is to just remove the install_command line (and also the download line). It was added in 821562513526dcd439b253f25677cc2c998d8fef but is no longer necessary. According to tox docs, the default command is python -I -m pip install {opts} {packages} so already isolated :+1: