mirror of
https://github.com/python/cpython.git
synced 2025-07-23 03:05:38 +00:00
gh-94619: Remove long deprecated methods module_repr() and load_module() (#94624)
* gh-94619: Remove long deprecated methods module_repr() and load_module() Closes #94619 * Update Misc/NEWS.d/next/Library/2022-07-06-14-57-33.gh-issue-94619.PRqKVX.rst Fix typo Co-authored-by: Brett Cannon <brett@python.org> Co-authored-by: Brett Cannon <brett@python.org>
This commit is contained in:
parent
44f1f63ad5
commit
e1182bc377
12 changed files with 11 additions and 180 deletions
|
@ -8,10 +8,10 @@ from test.support.script_helper import assert_python_ok
|
|||
import sys
|
||||
ModuleType = type(sys)
|
||||
|
||||
|
||||
class FullLoader:
|
||||
@classmethod
|
||||
def module_repr(cls, m):
|
||||
return "<module '{}' (crafted)>".format(m.__name__)
|
||||
pass
|
||||
|
||||
|
||||
class BareLoader:
|
||||
pass
|
||||
|
@ -236,7 +236,7 @@ a = A(destroyed)"""
|
|||
# Yes, a class not an instance.
|
||||
m.__loader__ = FullLoader
|
||||
self.assertEqual(
|
||||
repr(m), "<module 'foo' (crafted)>")
|
||||
repr(m), "<module 'foo' (<class 'test.test_module.FullLoader'>)>")
|
||||
|
||||
def test_module_repr_with_bare_loader_and_filename(self):
|
||||
# Because the loader has no module_repr(), use the file name.
|
||||
|
@ -252,7 +252,7 @@ a = A(destroyed)"""
|
|||
# Yes, a class not an instance.
|
||||
m.__loader__ = FullLoader
|
||||
m.__file__ = '/tmp/foo.py'
|
||||
self.assertEqual(repr(m), "<module 'foo' (crafted)>")
|
||||
self.assertEqual(repr(m), "<module 'foo' from '/tmp/foo.py'>")
|
||||
|
||||
def test_module_repr_builtin(self):
|
||||
self.assertEqual(repr(sys), "<module 'sys' (built-in)>")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue