(self)
| 678 | return pickle.loads(pickled) |
| 679 | |
| 680 | def test_attrgetter(self): |
| 681 | attrgetter = self.module.attrgetter |
| 682 | class A: |
| 683 | pass |
| 684 | a = A() |
| 685 | a.x = 'X' |
| 686 | a.y = 'Y' |
| 687 | a.z = 'Z' |
| 688 | a.t = A() |
| 689 | a.t.u = A() |
| 690 | a.t.u.v = 'V' |
| 691 | for proto in range(pickle.HIGHEST_PROTOCOL + 1): |
| 692 | with self.subTest(proto=proto): |
| 693 | f = attrgetter('x') |
| 694 | f2 = self.copy(f, proto) |
| 695 | self.assertEqual(repr(f2), repr(f)) |
| 696 | self.assertEqual(f2(a), f(a)) |
| 697 | # multiple gets |
| 698 | f = attrgetter('x', 'y', 'z') |
| 699 | f2 = self.copy(f, proto) |
| 700 | self.assertEqual(repr(f2), repr(f)) |
| 701 | self.assertEqual(f2(a), f(a)) |
| 702 | # recursive gets |
| 703 | f = attrgetter('t.u.v') |
| 704 | f2 = self.copy(f, proto) |
| 705 | self.assertEqual(repr(f2), repr(f)) |
| 706 | self.assertEqual(f2(a), f(a)) |
| 707 | |
| 708 | def test_itemgetter(self): |
| 709 | itemgetter = self.module.itemgetter |
nothing calls this directly
no test coverage detected