holger krekel  committed 9b7878f Merge

Merged in g2p/tox (pull request #32)

Give further hints on py.test discovery.

  • Participants
  • Parent commits 1b8bdf9, 8eb9f56
  • Branches default

Comments (0)

Files changed (1)

File doc/example/pytest.txt

 **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 ```` 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
-```` files in test directories and also try to avoid custom
-``PYTHONPATH`` settings.  After all, it is the job of your ````
-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 ````), 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
+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
+```` 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
 .. _`fully qualified name`:
+.. _`Distribute's 2to3 support`:
 .. include:: ../links.txt