fix(tests): skip packaging test gracefully when setuptools is absent - #35050
Closed
teknium1 wants to merge 1 commit into
Closed
fix(tests): skip packaging test gracefully when setuptools is absent#35050teknium1 wants to merge 1 commit into
teknium1 wants to merge 1 commit into
Conversation
tests/test_packaging_metadata.py imported 'from setuptools import find_packages' at module top level. setuptools is only a build-system requirement ([build-system].requires), not a runtime/test dependency, so lean test environments (some CI slices, slim containers) may not have it installed. When absent, the module-level import raised ModuleNotFoundError at COLLECTION time, which failed the entire test slice — taking the other three packaging tests (faster-whisper, MANIFEST, plugin-manifest) down with it even though they don't need setuptools. Fix: detect availability via importlib.util.find_spec at module level (no import error), gate the one test that needs find_packages behind @pytest.mark.skipif, and defer the actual import into the test body. The other three tests now run regardless.
Contributor
Author
|
Superseded by #34851, which landed on main a few minutes before this and fixes the same root cause two ways: declares setuptools==82.0.1 in the [dev] extra AND guards the import with pytest.importorskip. Closing as redundant. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tests/test_packaging_metadata.pyno longer fails the whole test slice whensetuptoolsisn't installed.Root cause
The module imported
from setuptools import find_packagesat the top level.setuptoolsis only a build-system requirement ([build-system].requiresinpyproject.toml), not a runtime or test dependency. In lean test environments that install only runtime + dev deps (some CI slices, slim containers),setuptoolsmay be absent — and the module-level import then raisedModuleNotFoundErrorat collection time, which failed the entiretest (N)slice and took the other three packaging tests (faster-whisper, MANIFEST, plugin-manifest) down with it, even though they never use setuptools.Observed on the slice-1 shard:
4795 tests passed, 0 failed, but the slice still exited 1 because of this single collection error.Changes
tests/test_packaging_metadata.py:importlib.util.find_spec("setuptools")at module level (no import, no collection error).find_packagesbehind@pytest.mark.skipif.from setuptools import find_packagesinto the test body.Validation