summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-09-27 17:45:35 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-09-27 17:45:35 (GMT)
commit47dee11ba76a12d22277562b9ccea51259a5ecc0 (patch)
tree949a4eaa4034f1ed15e84e46178b666d07cff6e2 /Lib
parentc0b7037d4fc0f85af858cfa56df4dca25fb8896f (diff)
downloadcpython-47dee11ba76a12d22277562b9ccea51259a5ecc0.zip
cpython-47dee11ba76a12d22277562b9ccea51259a5ecc0.tar.gz
cpython-47dee11ba76a12d22277562b9ccea51259a5ecc0.tar.bz2
Issue #21578: Fixed misleading error message when ImportError called with
invalid keyword args.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_exceptions.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py
index 458ddc1..96c3a48 100644
--- a/Lib/test/test_exceptions.py
+++ b/Lib/test/test_exceptions.py
@@ -1096,6 +1096,23 @@ 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')
+
+ msg = "'invalid|another' is an invalid keyword argument for this function"
+ 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):