You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: doc/en/explanation/pythonpath.rst
+8-11
Original file line number
Diff line number
Diff line change
@@ -16,14 +16,14 @@ import process can be controlled through the ``--import-mode`` command-line flag
16
16
these values:
17
17
18
18
* ``prepend`` (default): the directory path containing each module will be inserted into the *beginning*
19
-
of ``sys.path`` if not already there, and then imported with the `__import__ <https://docs.python.org/3/library/functions.html#__import__>`__ builtin.
19
+
of :py:data:`sys.path` if not already there, and then imported with the `__import__ <https://docs.python.org/3/library/functions.html#__import__>`__ builtin.
20
20
21
21
This requires test module names to be unique when the test directory tree is not arranged in
22
-
packages, because the modules will put in ``sys.modules`` after importing.
22
+
packages, because the modules will put in :py:data:`sys.modules` after importing.
23
23
24
24
This is the classic mechanism, dating back from the time Python 2 was still supported.
25
25
26
-
* ``append``: the directory containing each module is appended to the end of ``sys.path`` if not already
26
+
* ``append``: the directory containing each module is appended to the end of :py:data:`sys.path` if not already
27
27
there, and imported with ``__import__``.
28
28
29
29
This better allows to run test modules against installed versions of a package even if the
@@ -41,17 +41,14 @@ these values:
41
41
we advocate for using :ref:`src <src-layout>` layouts.
42
42
43
43
Same as ``prepend``, requires test module names to be unique when the test directory tree is
44
-
not arranged in packages, because the modules will put in ``sys.modules`` after importing.
44
+
not arranged in packages, because the modules will put in :py:data:`sys.modules` after importing.
45
45
46
-
* ``importlib``: new in pytest-6.0, this mode uses `importlib <https://docs.python.org/3/library/importlib.html>`__ to import test modules. This gives full control over the import process, and doesn't require
47
-
changing ``sys.path`` or ``sys.modules`` at all.
46
+
* ``importlib``: new in pytest-6.0, this mode uses `importlib <https://docs.python.org/3/library/importlib.html>`__ to import test modules. This gives full control over the import process, and doesn't require changing :py:data:`sys.path`.
48
47
49
-
For this reason this doesn't require test module names to be unique at all, but also makes test
50
-
modules non-importable by each other. This was made possible in previous modes, for tests not residing
51
-
in Python packages, because of the side-effects of changing ``sys.path`` and ``sys.modules``
52
-
mentioned above. Users which require this should turn their tests into proper packages instead.
48
+
For this reason this doesn't require test module names to be unique, but also makes test
49
+
modules non-importable by each other.
53
50
54
-
We intend to make ``importlib`` the default in future releases.
51
+
We intend to make ``importlib`` the default in future releases, depending on feedback.
0 commit comments