mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-76785: Add _PyType_GetModuleName() to the Internal C-API (gh-112323)
The new function corresponds to the existing (public) PyType_GetName() and PyType_GetQualName().
This commit is contained in:
parent
5c3a129ecf
commit
790db85c77
5 changed files with 43 additions and 0 deletions
|
@ -1098,6 +1098,21 @@ class CAPITest(unittest.TestCase):
|
|||
del d.extra
|
||||
self.assertIsNone(d.extra)
|
||||
|
||||
def test_get_type_module_name(self):
|
||||
from collections import OrderedDict
|
||||
ht = _testcapi.get_heaptype_for_name()
|
||||
for cls, expected in {
|
||||
int: 'builtins',
|
||||
OrderedDict: 'collections',
|
||||
ht: '_testcapi',
|
||||
}.items():
|
||||
with self.subTest(repr(cls)):
|
||||
modname = _testinternalcapi.get_type_module_name(cls)
|
||||
self.assertEqual(modname, expected)
|
||||
|
||||
ht.__module__ = 'test_module'
|
||||
modname = _testinternalcapi.get_type_module_name(ht)
|
||||
self.assertEqual(modname, 'test_module')
|
||||
|
||||
@requires_limited_api
|
||||
class TestHeapTypeRelative(unittest.TestCase):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue