summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-04-23 07:51:39 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-04-23 07:51:39 (GMT)
commitc2a2a751cf02f603c979817b0927b238ec0f141f (patch)
tree5f115824526e22326c18fafb02d6a4229a22d72b /Lib
parent95b5f0ad7ee08c88b749bba2bf229a27f0e89b62 (diff)
downloadcpython-c2a2a751cf02f603c979817b0927b238ec0f141f.zip
cpython-c2a2a751cf02f603c979817b0927b238ec0f141f.tar.gz
cpython-c2a2a751cf02f603c979817b0927b238ec0f141f.tar.bz2
Issue #26822: itemgetter, attrgetter and methodcaller objects no longer
silently ignore keyword arguments.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_operator.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_operator.py b/Lib/test/test_operator.py
index da9c8ef..b5ba976 100644
--- a/Lib/test/test_operator.py
+++ b/Lib/test/test_operator.py
@@ -318,6 +318,9 @@ class OperatorTestCase:
a.name = 'arthur'
f = operator.attrgetter('name')
self.assertEqual(f(a), 'arthur')
+ self.assertRaises(TypeError, f)
+ self.assertRaises(TypeError, f, a, 'dent')
+ self.assertRaises(TypeError, f, a, surname='dent')
f = operator.attrgetter('rank')
self.assertRaises(AttributeError, f, a)
self.assertRaises(TypeError, operator.attrgetter, 2)
@@ -365,6 +368,9 @@ class OperatorTestCase:
a = 'ABCDE'
f = operator.itemgetter(2)
self.assertEqual(f(a), 'C')
+ self.assertRaises(TypeError, f)
+ self.assertRaises(TypeError, f, a, 3)
+ self.assertRaises(TypeError, f, a, size=3)
f = operator.itemgetter(10)
self.assertRaises(IndexError, f, a)
@@ -411,6 +417,9 @@ class OperatorTestCase:
self.assertRaises(IndexError, f, a)
f = operator.methodcaller('foo', 1, 2)
self.assertEqual(f(a), 3)
+ self.assertRaises(TypeError, f)
+ self.assertRaises(TypeError, f, a, 3)
+ self.assertRaises(TypeError, f, a, spam=3)
f = operator.methodcaller('bar')
self.assertEqual(f(a), 42)
self.assertRaises(TypeError, f, a, a)