Replace deprecated json.__version__ with test fixture module in tests#5189
Open
Replace deprecated json.__version__ with test fixture module in tests#5189
Conversation
json.__version__ was deprecated in Python 3.15 (slated for removal in 3.20) and is now provided via module __getattr__ rather than as a bytecode constant. This causes TestDepends.testModuleExtract and TestDepends.testRequire to fail because get_module_constant cannot extract attributes set through __getattr__. Replace the json module references with the existing test fixture module (setuptools.tests.mod_with_constant), adding a __version__ constant to it. This makes the tests independent of stdlib deprecation cycles while still exercising the same code paths. Fixes pypa#5186
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
Fixes #5186
json.__version__was deprecated in Python 3.15 (slated for removal in 3.20) and is now provided via module__getattr__rather than as a bytecode constant. This causesTestDepends.testModuleExtractandTestDepends.testRequireto fail on Python 3.15+ becauseget_module_constantcannot extract attributes set through__getattr__.Changes
__version__ = '1.0.3'constant to the existing test fixture modulesetuptools/tests/mod_with_constant.pytestModuleExtractto usesetuptools.tests.mod_with_constantinstead ofjsontestRequireto usesetuptools.tests.mod_with_constantinstead ofjsonThis makes the tests independent of stdlib deprecation cycles while still exercising the same
get_module_constantandRequirecode paths. The test fixture module has a real bytecode constant assignment, which is exactly what these tests need to verify.