Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions setuptools/tests/mod_with_constant.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
value = 'three, sir!'
__version__ = '1.0.3'
24 changes: 17 additions & 7 deletions setuptools/tests/test_setuptools.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,16 @@ def testFindModule(self):

@needs_bytecode
def testModuleExtract(self):
from json import __version__
# Use a test fixture module instead of json, whose __version__ was
# deprecated in Python 3.15 and moved behind __getattr__ (gh-5186).
from setuptools.tests.mod_with_constant import __version__

assert dep.get_module_constant('json', '__version__') == __version__
assert (
dep.get_module_constant(
'setuptools.tests.mod_with_constant', '__version__'
)
== __version__
)
assert dep.get_module_constant('sys', 'version') == sys.version
assert (
dep.get_module_constant('setuptools.tests.test_setuptools', '__doc__')
Expand All @@ -90,15 +97,18 @@ def testModuleExtract(self):

@needs_bytecode
def testRequire(self):
req = Require('Json', '1.0.3', 'json')
# Use a test fixture module instead of json, whose __version__ was
# deprecated in Python 3.15 and moved behind __getattr__ (gh-5186).
mod_name = 'setuptools.tests.mod_with_constant'
req = Require('ModWithConstant', '1.0.3', mod_name)

assert req.name == 'Json'
assert req.module == 'json'
assert req.name == 'ModWithConstant'
assert req.module == mod_name
assert req.requested_version == Version('1.0.3')
assert req.attribute == '__version__'
assert req.full_name() == 'Json-1.0.3'
assert req.full_name() == 'ModWithConstant-1.0.3'

from json import __version__
from setuptools.tests.mod_with_constant import __version__

assert str(req.get_version()) == __version__
assert req.version_ok('1.0.9')
Expand Down