[Pytest-commit] Issue #727: Doctests: CWD vs PATH import ambiguity (pytest-dev/pytest)

Andrew Pashkin issues-reply at bitbucket.org
Wed Apr 22 11:33:23 CEST 2015


New issue 727: Doctests: CWD vs PATH import ambiguity
https://bitbucket.org/pytest-dev/pytest/issue/727/doctests-cwd-vs-path-import-ambiguity

Andrew Pashkin:

Currently, when invoked with `--doctest-modules` option, Pytest imports modules from current working directory, which in some cases might break testing if it require to import package installed by `setup.py`. For example package can contain C-extensions - they can not be imported from project repository root, they need to be prepared for that by `distutils`. 

I see two strategies of resolving this issue:

1. Make Pytest prefer installed packages to packages from CWD
2. Make possible to explicitly set module(s) that py.test must import, so instead of `py.test --doctest-modules ./mypkg` invokation will look like `py.test --doctest-modules mypkg.*` or `py.test --doctest-modules mypkg.foo.bar`. I like this way more, because it completely unambugous - user will immediately understand, that Pytest will do `from mypkg.foo import bar` with respect to PATH. And PATH may contain either `site-packages` or current working directory.




More information about the pytest-commit mailing list