diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2010-10-31 15:26:04 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2010-10-31 15:26:04 (GMT) |
commit | e974571d36009e327a97bb83389cf05c2b858288 (patch) | |
tree | 2f4985227e462222cdb88331aa6aa04c29d71a00 /Lib/test/test_operator.py | |
parent | 65b4af34d706206f45f0a4fb5768548b176f977e (diff) | |
download | cpython-e974571d36009e327a97bb83389cf05c2b858288.zip cpython-e974571d36009e327a97bb83389cf05c2b858288.tar.gz cpython-e974571d36009e327a97bb83389cf05c2b858288.tar.bz2 |
Issue #10160: Speed up operator.attrgetter. Patch by Christos Georgiou.
Diffstat (limited to 'Lib/test/test_operator.py')
-rw-r--r-- | Lib/test/test_operator.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Lib/test/test_operator.py b/Lib/test/test_operator.py index aa3219f..f291e52 100644 --- a/Lib/test/test_operator.py +++ b/Lib/test/test_operator.py @@ -275,8 +275,7 @@ class OperatorTestCase(unittest.TestCase): self.assertEqual(f(a), 'arthur') f = operator.attrgetter('rank') self.assertRaises(AttributeError, f, a) - f = operator.attrgetter(2) - self.assertRaises(TypeError, f, a) + self.assertRaises(TypeError, operator.attrgetter, 2) self.assertRaises(TypeError, operator.attrgetter) # multiple gets @@ -285,7 +284,7 @@ class OperatorTestCase(unittest.TestCase): record.y = 'Y' record.z = 'Z' self.assertEqual(operator.attrgetter('x','z','y')(record), ('X', 'Z', 'Y')) - self.assertRaises(TypeError, operator.attrgetter('x', (), 'y'), record) + self.assertRaises(TypeError, operator.attrgetter, ('x', (), 'y')) class C(object): def __getattr__(self, name): @@ -304,6 +303,10 @@ class OperatorTestCase(unittest.TestCase): self.assertEqual(f(a), ('arthur', 'thomas')) f = operator.attrgetter('name', 'child.name', 'child.child.name') self.assertRaises(AttributeError, f, a) + f = operator.attrgetter('child.') + self.assertRaises(AttributeError, f, a) + f = operator.attrgetter('.child') + self.assertRaises(AttributeError, f, a) a.child.child = A() a.child.child.name = 'johnson' |