diff options
author | Berker Peksag <berker.peksag@gmail.com> | 2015-03-12 18:42:48 (GMT) |
---|---|---|
committer | Berker Peksag <berker.peksag@gmail.com> | 2015-03-12 18:42:48 (GMT) |
commit | 9bd8af788d4f788ae678898b5edff035fe2b9a8e (patch) | |
tree | 67e57a7ee03bcb0af6cd173a8d158b5dfc7aa21a /Lib/unittest/test | |
parent | 4a0e14730b8cc6ae5b13d634069ea38fa08bc24a (diff) | |
download | cpython-9bd8af788d4f788ae678898b5edff035fe2b9a8e.zip cpython-9bd8af788d4f788ae678898b5edff035fe2b9a8e.tar.gz cpython-9bd8af788d4f788ae678898b5edff035fe2b9a8e.tar.bz2 |
Issue #23581: Add matmul support to MagicMock.
Patch by Håkan Lövdahl.
Diffstat (limited to 'Lib/unittest/test')
-rw-r--r-- | Lib/unittest/test/testmock/testmagicmethods.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/unittest/test/testmock/testmagicmethods.py b/Lib/unittest/test/testmock/testmagicmethods.py index cc0e707..f4a292a 100644 --- a/Lib/unittest/test/testmock/testmagicmethods.py +++ b/Lib/unittest/test/testmock/testmagicmethods.py @@ -424,5 +424,16 @@ class TestMockingMagicMethods(unittest.TestCase): self.assertEqual(list(m), []) + def test_matmul(self): + m = MagicMock() + self.assertIsInstance(m @ 1, MagicMock) + m.__matmul__.return_value = 42 + m.__rmatmul__.return_value = 666 + m.__imatmul__.return_value = 24 + self.assertEqual(m @ 1, 42) + self.assertEqual(1 @ m, 666) + m @= 24 + self.assertEqual(m, 24) + if __name__ == '__main__': unittest.main() |