forked from pytest-dev/pytest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This introduces --import-mode=importlib, which uses fine-grained facilities from importlib to import test modules and conftest files, bypassing the need to change sys.path and sys.modules as side-effect of that. I've also opened pytest-dev#7245 to gather feedback on the new import mode.
- Loading branch information
1 parent
322190f
commit 58d84e3
Showing
8 changed files
with
148 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
New ``--import-mode=importlib`` option that uses `importlib <https://docs.python.org/3/library/importlib.html>`__ to import test modules. | ||
|
||
Traditionally pytest used ``__import__`` while changing ``sys.path`` to import test modules (which | ||
also changes ``sys.modules`` as a side-effect), which works but has a number of drawbacks, like requiring test modules | ||
that don't live in packages to have unique names (as they need to reside under a unique name in ``sys.modules``). | ||
|
||
``--import-mode=importlib`` uses more fine grained import mechanisms from ``importlib`` which don't | ||
require pytest to change ``sys.path`` or ``sys.modules`` at all, eliminating much of the drawbacks | ||
of the previous mode. | ||
|
||
We intend to make ``--import-mode=importlib`` the default in future versions, so users are encouraged | ||
to try the new mode and provide feedback (both positive or negative) in issue `#7245 <https://github.com/pytest-dev/pytest/issues/7245>`__. | ||
|
||
You can read more about this option in `the documentation <https://docs.pytest.org/en/latest/pythonpath.html#import-modes>`__. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters