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
+3-3
Original file line number
Diff line number
Diff line change
@@ -16,15 +16,15 @@ 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 :py:data:`sys.path` if not already there, and then imported with the :func:`__import__ <__import__>` builtin.
19
+
of :py:data:`sys.path` if not already there, and then imported with the :func:`importlib.import_module <importlib.import_module>` function.
20
20
21
21
This requires test module names to be unique when the test directory tree is not arranged in
22
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
26
* ``append``: the directory containing each module is appended to the end of :py:data:`sys.path` if not already
27
-
there, and imported with ``__import__``.
27
+
there, and imported with :func:`importlib.import_module <importlib.import_module>`.
28
28
29
29
This better allows to run test modules against installed versions of a package even if the
30
30
package under test has the same import root. For example:
@@ -43,7 +43,7 @@ these values:
43
43
Same as ``prepend``, requires test module names to be unique when the test directory tree is
44
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 :mod:`importlib` to import test modules. This gives full control over the import process, and doesn't require changing :py:data:`sys.path`.
46
+
* ``importlib``: new in pytest-6.0, this mode uses more fine control mechanisms provided by :mod:`importlib` to import test modules. This gives full control over the import process, and doesn't require changing :py:data:`sys.path`.
47
47
48
48
For this reason this doesn't require test module names to be unique.
0 commit comments