(self)
| 721 | self.assertEqual(f2(a), f(a)) |
| 722 | |
| 723 | def test_methodcaller(self): |
| 724 | methodcaller = self.module.methodcaller |
| 725 | class A: |
| 726 | def foo(self, *args, **kwds): |
| 727 | return args[0] + args[1] |
| 728 | def bar(self, f=42): |
| 729 | return f |
| 730 | def baz(*args, **kwds): |
| 731 | return kwds['name'], kwds['self'] |
| 732 | a = A() |
| 733 | for proto in range(pickle.HIGHEST_PROTOCOL + 1): |
| 734 | with self.subTest(proto=proto): |
| 735 | f = methodcaller('bar') |
| 736 | f2 = self.copy(f, proto) |
| 737 | self.assertEqual(repr(f2), repr(f)) |
| 738 | self.assertEqual(f2(a), f(a)) |
| 739 | # positional args |
| 740 | f = methodcaller('foo', 1, 2) |
| 741 | f2 = self.copy(f, proto) |
| 742 | self.assertEqual(repr(f2), repr(f)) |
| 743 | self.assertEqual(f2(a), f(a)) |
| 744 | # keyword args |
| 745 | f = methodcaller('bar', f=5) |
| 746 | f2 = self.copy(f, proto) |
| 747 | self.assertEqual(repr(f2), repr(f)) |
| 748 | self.assertEqual(f2(a), f(a)) |
| 749 | f = methodcaller('baz', self='eggs', name='spam') |
| 750 | f2 = self.copy(f, proto) |
| 751 | # Can't test repr consistently with multiple keyword args |
| 752 | self.assertEqual(f2(a), f(a)) |
| 753 | |
| 754 | class PyPyOperatorPickleTestCase(OperatorPickleTestCase, unittest.TestCase): |
| 755 | module = py_operator |
nothing calls this directly
no test coverage detected