pytest: Inconsistent behaviour of `python3 -m pytest` and `py.test`
See http://pastebin.com/52ra33eN
Both commands show
platform linux -- Python 3.4.3 -- py-1.4.30 -- pytest-2.7.2
rootdir: /home/lasse/prog/PyPrint, inifile: setup.cfg
plugins: spec, cov, xdist
but py.test
isn’t able to get the imports right.
Steps to reproduce:
git clone https://github.com/coala-analyzer/PyPrint
git checkout pytestrep
(Auto sync with origin/pytestrep)py.test
/python3 -m pytest
in a python3 environment
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 26 (22 by maintainers)
Seeing the same problem, python3 -m pytest works and py.test doesn’t for xonsh. it is a PYTHONPATH issue and the docs are very misleading in http://docs.pytest.org/en/latest/usage.html#cmdline:
python -m pytest […] This is equivalent to invoking the command line script py.test […] directly.
no they are not, exactly because of pythonpath. Can we just do that on py.test?
Late to the party, but I strongly agree with not changing pytest to harmonize the
pytest
vspython -m pytest
behaviors.The path-modified behavior of
python -m
is an intrinsic feature of the language, and shimming a tool to paper over it is a bad idea for lots of reasons, not least of which is that it would make pytest inconsistent with other tooling that has not been likewise shimmed.More-prominent advertising/education of the
python -m
path-modification behavior is the best approach, IMO, b/c it (1) addresses the root cause, and (2) is equally applicable across the Python ecosystem.Also: thank you for this great tool! 👏
@DuncanBetts I’m not sure I follow, it seems the error is not really related to
--pyargs
, but the fact thatpython -m pytest
implicitly adds the current directory toPYTHONPATH
.Either way I think updating the documentation would be a good first step as well.
@sils1297 this is a artifact of the new style namespaces