3 new commits in tox: https://bitbucket.org/hpk42/tox/commits/1538fe9d3a7c/ Changeset: 1538fe9d3a7c User: g2p Date: 2012-12-03 18:14:25 Summary: Give further hints on py.test discovery. Affected #: 1 file
diff -r e913d5105cc0d286f93bf53f2e30389c292fbbc7 -r 1538fe9d3a7c8334abcc5b342afe2133af889deb doc/example/pytest.txt --- a/doc/example/pytest.txt +++ b/doc/example/pytest.txt @@ -85,14 +85,20 @@ **installed-versus-checkout version**. ``py.test`` collects test modules on the filesystem and then tries to import them under their -`fully qualified name`_. This means that if your test directory contains -an ``__init__.py`` file then your ``py.test`` invocation may end up +`fully qualified name`_. This means that if your test files are +importable from somewhere then your ``py.test`` invocation may end up importing the package from the checkout directory rather than the -installed package. Therefore it is better to try to avoid -``__init__.py`` files in test directories and also try to avoid custom -``PYTHONPATH`` settings. After all, it is the job of your ``setup.py`` -file and the install tools to care for making the package properly -available for importing. +installed package. + +There are a few ways to prevent this. + +With installed tests (the tests are built and installed by setup.py), +one option is to give the explicit path ``{envsitepackagesdir}/mypkg`` +to pytest, and another is to change directories and pass ``--pyargs +mypkg``. With tests that won't be installed, the simplest way is to +avoid ``__init__.py`` files in test directories; pytest will still find +them but they won't be copied to other places and they won't be found by +Python's import system. .. _`fully qualified name`: http://pytest.org/latest/goodpractises.html#package-name https://bitbucket.org/hpk42/tox/commits/8eb9f56e0dd0/ Changeset: 8eb9f56e0dd0 User: g2p Date: 2012-12-03 21:45:13 Summary: Relate to the 2to3 use case. Affected #: 1 file diff -r 1538fe9d3a7c8334abcc5b342afe2133af889deb -r 8eb9f56e0dd068ceaac4328239097230e4a94ba8 doc/example/pytest.txt --- a/doc/example/pytest.txt +++ b/doc/example/pytest.txt @@ -92,15 +92,23 @@ There are a few ways to prevent this. -With installed tests (the tests are built and installed by setup.py), -one option is to give the explicit path ``{envsitepackagesdir}/mypkg`` -to pytest, and another is to change directories and pass ``--pyargs -mypkg``. With tests that won't be installed, the simplest way is to -avoid ``__init__.py`` files in test directories; pytest will still find -them but they won't be copied to other places and they won't be found by -Python's import system. +With installed tests (the tests packages are known to ``setup.py``), a +safe and explicit option is to give the explicit path +``{envsitepackagesdir}/mypkg`` to pytest. +Alternatively, it is possible to use ``changedir`` so that checked-out +files are outside the import path, then pass ``--pyargs mypkg`` to +pytest. + +Installed tests are particularly convenient when combined with +`Distribute's 2to3 support` (``use_2to3``). + +With tests that won't be installed, the simplest way is to avoid +``__init__.py`` files in test directories; pytest will still find them +but they won't be copied to other places or be found by Python's import +system. .. _`fully qualified name`: http://pytest.org/latest/goodpractises.html#package-name +.. _`Distribute's 2to3 support`: http://packages.python.org/distribute/python3.html .. include:: ../links.txt https://bitbucket.org/hpk42/tox/commits/9b7878f71a1e/ Changeset: 9b7878f71a1e User: hpk42 Date: 2013-04-25 20:23:37 Summary: Merged in g2p/tox (pull request #32) Give further hints on py.test discovery. Affected #: 1 file diff -r 1b8bdf9ab87e87203df8543b8e5a85bc30433f52 -r 9b7878f71a1e3846c3a36264fcf322d75682ba19 doc/example/pytest.txt --- a/doc/example/pytest.txt +++ b/doc/example/pytest.txt @@ -85,16 +85,30 @@ **installed-versus-checkout version**. ``py.test`` collects test modules on the filesystem and then tries to import them under their -`fully qualified name`_. This means that if your test directory contains -an ``__init__.py`` file then your ``py.test`` invocation may end up +`fully qualified name`_. This means that if your test files are +importable from somewhere then your ``py.test`` invocation may end up importing the package from the checkout directory rather than the -installed package. Therefore it is better to try to avoid -``__init__.py`` files in test directories and also try to avoid custom -``PYTHONPATH`` settings. After all, it is the job of your ``setup.py`` -file and the install tools to care for making the package properly -available for importing. +installed package. + +There are a few ways to prevent this. + +With installed tests (the tests packages are known to ``setup.py``), a +safe and explicit option is to give the explicit path +``{envsitepackagesdir}/mypkg`` to pytest. +Alternatively, it is possible to use ``changedir`` so that checked-out +files are outside the import path, then pass ``--pyargs mypkg`` to +pytest. + +Installed tests are particularly convenient when combined with +`Distribute's 2to3 support` (``use_2to3``). + +With tests that won't be installed, the simplest way is to avoid +``__init__.py`` files in test directories; pytest will still find them +but they won't be copied to other places or be found by Python's import +system. .. _`fully qualified name`: http://pytest.org/latest/goodpractises.html#package-name +.. _`Distribute's 2to3 support`: http://packages.python.org/distribute/python3.html .. include:: ../links.txt Repository URL: https://bitbucket.org/hpk42/tox/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. _______________________________________________ pytest-commit mailing list pytest-commit@python.org http://mail.python.org/mailman/listinfo/pytest-commit