diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-09-28 07:53:32 +0300 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-09-28 07:53:32 +0300 |
commit | e9e44484a51d4caab2a28c883dccb7321828abde (patch) | |
tree | a038f8ab6be7663a89cd09839fbb75593bffe7d1 /Lib/test/test_exceptions.py | |
parent | 2e8c939e3d8103cd4f236754764858cb23342ab3 (diff) | |
download | cpython-e9e44484a51d4caab2a28c883dccb7321828abde.tar.gz cpython-e9e44484a51d4caab2a28c883dccb7321828abde.zip |
Issue #28289: ImportError.__init__ now resets not specified attributes.
Diffstat (limited to 'Lib/test/test_exceptions.py')
-rw-r--r-- | Lib/test/test_exceptions.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py index 48379222c37..34265a517f2 100644 --- a/Lib/test/test_exceptions.py +++ b/Lib/test/test_exceptions.py @@ -1112,6 +1112,20 @@ class ImportErrorTests(unittest.TestCase): with self.assertRaisesRegex(TypeError, msg): ImportError('test', invalid='keyword', another=True) + def test_reset_attributes(self): + exc = ImportError('test', name='name', path='path') + self.assertEqual(exc.args, ('test',)) + self.assertEqual(exc.msg, 'test') + self.assertEqual(exc.name, 'name') + self.assertEqual(exc.path, 'path') + + # Reset not specified attributes + exc.__init__() + self.assertEqual(exc.args, ()) + self.assertEqual(exc.msg, None) + self.assertEqual(exc.name, None) + self.assertEqual(exc.path, None) + def test_non_str_argument(self): # Issue #15778 with check_warnings(('', BytesWarning), quiet=True): |