Skip to content

Comments

Replace deprecated json.__version__ with test fixture module in tests#5189

Open
stakeswky wants to merge 1 commit intopypa:mainfrom
stakeswky:fix/replace-deprecated-json-version-in-tests
Open

Replace deprecated json.__version__ with test fixture module in tests#5189
stakeswky wants to merge 1 commit intopypa:mainfrom
stakeswky:fix/replace-deprecated-json-version-in-tests

Conversation

@stakeswky
Copy link

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 causes TestDepends.testModuleExtract and TestDepends.testRequire to fail on Python 3.15+ because get_module_constant cannot extract attributes set through __getattr__.

Changes

  • Added a __version__ = '1.0.3' constant to the existing test fixture module setuptools/tests/mod_with_constant.py
  • Updated testModuleExtract to use setuptools.tests.mod_with_constant instead of json
  • Updated testRequire to use setuptools.tests.mod_with_constant instead of json

This makes the tests independent of stdlib deprecation cycles while still exercising the same get_module_constant and Require code paths. The test fixture module has a real bytecode constant assignment, which is exactly what these tests need to verify.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

json.__version__ is deprecated and used in tests

1 participant