summaryrefslogtreecommitdiff
path: root/Lib/test/test_exceptions.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-09-27 20:51:04 +0300
committerSerhiy Storchaka <storchaka@gmail.com>2016-09-27 20:51:04 +0300
commit389ef9dcdabe3ed83023ea50deff4b1cd3927dd3 (patch)
tree9d1e729ee68e6c16c02879b961fc7fe217dbdd74 /Lib/test/test_exceptions.py
parenta12e7842a5f572afd6bde108f24931f9262f38ef (diff)
parent47dee11ba76a12d22277562b9ccea51259a5ecc0 (diff)
downloadcpython-git-389ef9dcdabe3ed83023ea50deff4b1cd3927dd3.tar.gz
Issue #21578: Fixed misleading error message when ImportError called with
invalid keyword args.
Diffstat (limited to 'Lib/test/test_exceptions.py')
-rw-r--r--Lib/test/test_exceptions.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py
index 458ddc1ed8..48379222c3 100644
--- a/Lib/test/test_exceptions.py
+++ b/Lib/test/test_exceptions.py
@@ -1096,6 +1096,22 @@ class ImportErrorTests(unittest.TestCase):
self.assertEqual(exc.name, 'somename')
self.assertEqual(exc.path, 'somepath')
+ msg = "'invalid' is an invalid keyword argument for this function"
+ with self.assertRaisesRegex(TypeError, msg):
+ ImportError('test', invalid='keyword')
+
+ with self.assertRaisesRegex(TypeError, msg):
+ ImportError('test', name='name', invalid='keyword')
+
+ with self.assertRaisesRegex(TypeError, msg):
+ ImportError('test', path='path', invalid='keyword')
+
+ with self.assertRaisesRegex(TypeError, msg):
+ ImportError(invalid='keyword')
+
+ with self.assertRaisesRegex(TypeError, msg):
+ ImportError('test', invalid='keyword', another=True)
+
def test_non_str_argument(self):
# Issue #15778
with check_warnings(('', BytesWarning), quiet=True):