diff options
| author | Ethan Furman <ethan@stoneleaf.us> | 2014-04-24 14:47:47 -0700 |
|---|---|---|
| committer | Ethan Furman <ethan@stoneleaf.us> | 2014-04-24 14:47:47 -0700 |
| commit | 7b9ff0e6da5371214b29053cdb96218e0d2eb655 (patch) | |
| tree | da11b0d718916d64a256d36fcc41287aca922e28 /Lib/test/test_module.py | |
| parent | 7101cb07ef8cb9e63b99b0e1c8200f355841772c (diff) | |
| download | cpython-git-7b9ff0e6da5371214b29053cdb96218e0d2eb655.tar.gz | |
Issue8297: module attribute lookup failures now include module name in error message.
Diffstat (limited to 'Lib/test/test_module.py')
| -rw-r--r-- | Lib/test/test_module.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_module.py b/Lib/test/test_module.py index 1230293670..5a22e69a8e 100644 --- a/Lib/test/test_module.py +++ b/Lib/test/test_module.py @@ -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") |
