diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2023-11-22 22:03:33 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-22 22:03:33 (GMT) |
commit | 790db85c7737c2ebbb145f9a26f675a586c5f0d1 (patch) | |
tree | 6f8e50af6d9e3eb470dc79a4d305eb77d79da9ae /Lib/test | |
parent | 5c3a129ecfbaac107bccf3083533276ee0ccc036 (diff) | |
download | cpython-790db85c7737c2ebbb145f9a26f675a586c5f0d1.zip cpython-790db85c7737c2ebbb145f9a26f675a586c5f0d1.tar.gz cpython-790db85c7737c2ebbb145f9a26f675a586c5f0d1.tar.bz2 |
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().
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_capi/test_misc.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_capi/test_misc.py b/Lib/test/test_capi/test_misc.py index 21a5cd3..6cbf5d2 100644 --- a/Lib/test/test_capi/test_misc.py +++ b/Lib/test/test_capi/test_misc.py @@ -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): |