diff options
author | Brett Cannon <brett@python.org> | 2021-03-24 15:26:56 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-24 15:26:56 (GMT) |
commit | 9cb31d671646a5ff0901f79d2d61022621447190 (patch) | |
tree | 07877b815e17e8def80ed4e70c385b4b3a23b5af /Lib/test/test_importlib | |
parent | 3ba3d513b1e3c63d09cb798b982a9e6c369cea4c (diff) | |
download | cpython-9cb31d671646a5ff0901f79d2d61022621447190.zip cpython-9cb31d671646a5ff0901f79d2d61022621447190.tar.gz cpython-9cb31d671646a5ff0901f79d2d61022621447190.tar.bz2 |
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).
Diffstat (limited to 'Lib/test/test_importlib')
-rw-r--r-- | Lib/test/test_importlib/frozen/test_loader.py | 8 | ||||
-rw-r--r-- | Lib/test/test_importlib/test_namespace_pkgs.py | 3 |
2 files changed, 2 insertions, 9 deletions
diff --git a/Lib/test/test_importlib/frozen/test_loader.py b/Lib/test/test_importlib/frozen/test_loader.py index 8eaffa7..632246a 100644 --- a/Lib/test/test_importlib/frozen/test_loader.py +++ b/Lib/test/test_importlib/frozen/test_loader.py @@ -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 diff --git a/Lib/test/test_importlib/test_namespace_pkgs.py b/Lib/test/test_importlib/test_namespace_pkgs.py index a8f95a0..ab5847c 100644 --- a/Lib/test/test_importlib/test_namespace_pkgs.py +++ b/Lib/test/test_importlib/test_namespace_pkgs.py @@ -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): |