mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
bpo-42137: have ModuleType.__repr__ prefer __spec__ over module_repr() (GH-24953)
This is to work towards the removal of the use of module_repr() in Python 3.12 (documented as deprecated since 3.4).
This commit is contained in:
parent
3ba3d513b1
commit
9cb31d6716
7 changed files with 147 additions and 153 deletions
|
@ -160,14 +160,6 @@ class LoaderTests(abc.LoaderTests):
|
|||
self.assertEqual(repr_str,
|
||||
"<module '__hello__' (frozen)>")
|
||||
|
||||
def test_module_repr_indirect(self):
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("ignore", DeprecationWarning)
|
||||
with util.uncache('__hello__'), captured_stdout():
|
||||
module = self.machinery.FrozenImporter.load_module('__hello__')
|
||||
self.assertEqual(repr(module),
|
||||
"<module '__hello__' (frozen)>")
|
||||
|
||||
# No way to trigger an error in a frozen module.
|
||||
test_state_after_failure = None
|
||||
|
||||
|
|
|
@ -82,7 +82,8 @@ class SingleNamespacePackage(NamespacePackageTest):
|
|||
|
||||
def test_module_repr(self):
|
||||
import foo.one
|
||||
self.assertEqual(repr(foo), "<module 'foo' (namespace)>")
|
||||
self.assertEqual(foo.__spec__.loader.module_repr(foo),
|
||||
"<module 'foo' (namespace)>")
|
||||
|
||||
|
||||
class DynamicPathNamespacePackage(NamespacePackageTest):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue