-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pytest >=8.1.1 displays no diff for AssertionError with --import-mode=importlib #12659
Comments
To be more precise, this phenomenon occurs in pytest >8.1.0. |
Reproduction Conditions:
Execution Process:
Error Cause:
If pkg_root fails to resolve, then Update:
Based on testing, this method is only suitable for importing modules from directories and is not applicable for importing packages and namespace packages from subdirectories. |
Fixes #12659 (cherry picked from commit 9a444d1) Co-authored-by: dongfangtianyu <[email protected]>
Description
It seems that from pytest
8.1.1
onwards, using--import-mode=importlib
causesAssertionError
to not render a diff in the shell output.8.0.2
worked just fine (as did 7.x).To reproduce, the test has to be within a package with a
__init__.py
present (which our tests are, for reasons).Reproduction
A clean environment:
python -m venv .venv source .venv/bin/activate pip install pytest==8.1.1 mkdir tests touch tests/__init__.py
And then put a simple test file in the tests dir:
And then run:
pytest --import-mode=importlib tests/test.py
Outputs:
Without a diff after the
AssertionError
If ran without
--import-mode=importlib
on8.0.2
the output shows the diff:Verbosity has no effect, no other packages need to be present (although setuptools etc from the default venv are).
Environment
Debian 12, python 3.11 (but also reproduced on 3.12 too)
The text was updated successfully, but these errors were encountered: