mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
bpo-42136: Deprecate module_repr() as found in importlib (GH-25022)
This commit is contained in:
parent
21a2cabb37
commit
1899087b21
11 changed files with 1545 additions and 1478 deletions
|
@ -220,8 +220,10 @@ class LoaderDefaultsTests(ABCTestHarness):
|
|||
|
||||
def test_module_repr(self):
|
||||
mod = types.ModuleType('blah')
|
||||
with self.assertRaises(NotImplementedError):
|
||||
self.ins.module_repr(mod)
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("ignore")
|
||||
with self.assertRaises(NotImplementedError):
|
||||
self.ins.module_repr(mod)
|
||||
original_repr = repr(mod)
|
||||
mod.__loader__ = self.ins
|
||||
# Should still return a proper repr.
|
||||
|
|
|
@ -3,6 +3,7 @@ import importlib
|
|||
import os
|
||||
import sys
|
||||
import unittest
|
||||
import warnings
|
||||
|
||||
from test.test_importlib import util
|
||||
|
||||
|
@ -82,8 +83,10 @@ class SingleNamespacePackage(NamespacePackageTest):
|
|||
|
||||
def test_module_repr(self):
|
||||
import foo.one
|
||||
self.assertEqual(foo.__spec__.loader.module_repr(foo),
|
||||
"<module 'foo' (namespace)>")
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("ignore")
|
||||
self.assertEqual(foo.__spec__.loader.module_repr(foo),
|
||||
"<module 'foo' (namespace)>")
|
||||
|
||||
|
||||
class DynamicPathNamespacePackage(NamespacePackageTest):
|
||||
|
|
|
@ -7,7 +7,6 @@ import sys
|
|||
import unittest
|
||||
from test import support
|
||||
from test.support import import_helper
|
||||
from distutils.util import get_platform
|
||||
from contextlib import contextmanager
|
||||
from .util import temp_module
|
||||
|
||||
|
@ -18,6 +17,25 @@ from winreg import (
|
|||
EnumKey, CloseKey, DeleteKey, OpenKey
|
||||
)
|
||||
|
||||
def get_platform():
|
||||
# Port of distutils.util.get_platform().
|
||||
TARGET_TO_PLAT = {
|
||||
'x86' : 'win32',
|
||||
'x64' : 'win-amd64',
|
||||
'arm' : 'win-arm32',
|
||||
}
|
||||
if ('VSCMD_ARG_TGT_ARCH' in os.environ and
|
||||
os.environ['VSCMD_ARG_TGT_ARCH'] in TARGET_TO_PLAT):
|
||||
return TARGET_TO_PLAT[os.environ['VSCMD_ARG_TGT_ARCH']]
|
||||
elif 'amd64' in sys.version.lower():
|
||||
return 'win-amd64'
|
||||
elif '(arm)' in sys.version.lower():
|
||||
return 'win-arm32'
|
||||
elif '(arm64)' in sys.version.lower():
|
||||
return 'win-arm64'
|
||||
else:
|
||||
return sys.platform
|
||||
|
||||
def delete_registry_tree(root, subkey):
|
||||
try:
|
||||
hkey = OpenKey(root, subkey, access=KEY_ALL_ACCESS)
|
||||
|
@ -101,7 +119,7 @@ class WindowsExtensionSuffixTests:
|
|||
|
||||
self.assertIn(expected_tag, suffixes)
|
||||
|
||||
# Ensure the tags are in the correct order
|
||||
# Ensure the tags are in the correct order.
|
||||
tagged_i = suffixes.index(expected_tag)
|
||||
self.assertLess(tagged_i, untagged_i)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue