diff options
author | Mark Shannon <mark@hotpy.org> | 2021-06-23 09:00:43 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-23 09:00:43 (GMT) |
commit | c3f52b4d707a78eb342372a2be00f3eb846a05b9 (patch) | |
tree | 1d5d5e7d4fe5cf7da492ed6eb79f019a43cb1946 /Lib/test/test_module.py | |
parent | 35b773accb41f09e40bf17bfaa5f0bc80796a26c (diff) | |
download | cpython-c3f52b4d707a78eb342372a2be00f3eb846a05b9.zip cpython-c3f52b4d707a78eb342372a2be00f3eb846a05b9.tar.gz cpython-c3f52b4d707a78eb342372a2be00f3eb846a05b9.tar.bz2 |
bpo-44486: Make sure that modules always have a dictionary. (GH-26847)
* Make sure that modules always have a dictionary.
Diffstat (limited to 'Lib/test/test_module.py')
-rw-r--r-- | Lib/test/test_module.py | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/Lib/test/test_module.py b/Lib/test/test_module.py index 65319d5..6608dbc 100644 --- a/Lib/test/test_module.py +++ b/Lib/test/test_module.py @@ -22,8 +22,8 @@ class ModuleTests(unittest.TestCase): # An uninitialized module has no __dict__ or __name__, # and __doc__ is None foo = ModuleType.__new__(ModuleType) - self.assertTrue(foo.__dict__ is None) - self.assertRaises(TypeError, dir, foo) + self.assertTrue(isinstance(foo.__dict__, dict)) + self.assertEqual(dir(foo), []) try: s = foo.__name__ self.fail("__name__ = %s" % repr(s)) @@ -318,15 +318,6 @@ a = A(destroyed)""" del foo.__dict__['__annotations__'] def test_annotations_getset_raises(self): - # module has no dict, all operations fail - foo = ModuleType.__new__(ModuleType) - with self.assertRaises(TypeError): - print(foo.__annotations__) - with self.assertRaises(TypeError): - foo.__annotations__ = {} - with self.assertRaises(TypeError): - del foo.__annotations__ - # double delete foo = ModuleType("foo") foo.__annotations__ = {} |