mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue8297: module attribute lookup failures now include module name in error message.
This commit is contained in:
parent
7101cb07ef
commit
7b9ff0e6da
5 changed files with 52 additions and 9 deletions
|
@ -30,6 +30,22 @@ class ModuleTests(unittest.TestCase):
|
|||
pass
|
||||
self.assertEqual(foo.__doc__, ModuleType.__doc__)
|
||||
|
||||
def test_unintialized_missing_getattr(self):
|
||||
# Issue 8297
|
||||
# test the text in the AttributeError of an uninitialized module
|
||||
foo = ModuleType.__new__(ModuleType)
|
||||
self.assertRaisesRegex(
|
||||
AttributeError, "module has no attribute 'not_here'",
|
||||
getattr, foo, "not_here")
|
||||
|
||||
def test_missing_getattr(self):
|
||||
# Issue 8297
|
||||
# test the text in the AttributeError
|
||||
foo = ModuleType("foo")
|
||||
self.assertRaisesRegex(
|
||||
AttributeError, "module 'foo' has no attribute 'not_here'",
|
||||
getattr, foo, "not_here")
|
||||
|
||||
def test_no_docstring(self):
|
||||
# Regularly initialized module, no docstring
|
||||
foo = ModuleType("foo")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue