pytest
pytest copied to clipboard
c85fce39b regressed importing standard library modules that are "masked"
- [x] a detailed description of the bug or problem you are having
- [x] output of
pip listfrom the virtual environment you are using - [x] pytest and operating system versions
- [x] minimal example if possible
As reported in this jaraco.test issue comment, this commit broke the ability to import test.support, which is in the standard library, while testing jaraco.test.
pip list:
abuild@conjecture:/home/abuild> pip list
Package Version
------------------ -----------------------
annotated-types 0.6.0
attrs 23.2.0
autocommand 2.2.2
backports.tarfile 1.0.0
inflect 7.0.0
iniconfig 2.0.0
jaraco.classes 3.4.0
jaraco.collections 5.0.1
jaraco.context 5.3.0
jaraco.functools 4.0.0
jaraco.text 3.12.0
more-itertools 10.2.0
packaging 24.0
pip 24.0
pluggy 1.5.0
pydantic 2.7.1
pydantic_core 2.18.2
pytest 8.1.0.dev253+gc85fce39b
setuptools 69.0.3
setuptools-scm 8.0.4
toml 0.10.2
typing_extensions 4.11.0
wheel 0.43.0
Operating system: openSUSE Tumbleweed
The minimal example would be running jaraco.test's testsuite under pytest, I guess.
This is one of the reasons we are reluctant to update pytest from 7 to 8 in Fedora Linux, but I am out of my league here. Could somebody please investigate? I can buy you a beverage at EuroPython if it helps :)
Turns out this doesn't just mask standard library modules, but any modules that are named the same:
From jaraco.packaging's testsuite:
[ 19s] __________________ [doctest] packaging.metadata.hunt_down_url __________________
[ 19s] 019
[ 19s] 020 Given project metadata, figure out what the package URL is.
[ 19s] 021
[ 19s] 022 >>> hunt_down_url(load('.'))
[ 19s] UNEXPECTED EXCEPTION: ModuleNotFoundError("No module named 'packaging.version'")
[ 19s] Traceback (most recent call last):
[ 19s] File "/usr/lib64/python3.10/doctest.py", line 1350, in __run
[ 19s] exec(compile(example.source, filename, "single",
[ 19s] File "<doctest packaging.metadata.hunt_down_url[0]>", line 1, in <module>
[ 19s] File "/home/abuild/rpmbuild/BUILD/jaraco_packaging-10.2.2/jaraco/packaging/metadata.py", line 15, in load
[ 19s] return util.project_wheel_metadata(source_dir, isolated, **kwargs)
[ 19s] File "/usr/lib/python3.10/site-packages/build/util.py", line 42, in project_wheel_metadata
[ 19s] with DefaultIsolatedEnv() as env:
[ 19s] File "/usr/lib/python3.10/site-packages/build/env.py", line 90, in __enter__
[ 19s] self._env_backend = _PipBackend()
[ 19s] File "/usr/lib/python3.10/site-packages/build/env.py", line 153, in __init__
[ 19s] self._create_with_virtualenv = not self._has_valid_outer_pip and self._has_virtualenv
[ 19s] File "/usr/lib64/python3.10/functools.py", line 981, in __get__
[ 19s] val = self.func(instance)
[ 19s] File "/usr/lib/python3.10/site-packages/build/env.py", line 162, in _has_valid_outer_pip
[ 19s] return _has_dependency('pip', '22.3')
[ 19s] File "/usr/lib/python3.10/site-packages/build/env.py", line 46, in _has_dependency
[ 19s] from packaging.version import Version
[ 19s] ModuleNotFoundError: No module named 'packaging.version'
Python 3.10.14 (main, Mar 21 2024, 16:45:28) [GCC] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import packaging.version
>>> packaging.version.__file__
'/usr/lib/python3.10/site-packages/packaging/version.py'
This first bit me with 8.2.0 and continues to do so.