mirror of
https://github.com/python/cpython.git
synced 2025-07-23 03:05:38 +00:00
Issue #23568: Add rdivmod support to MagicMock() objects.
Patch by Håkan Lövdahl.
This commit is contained in:
parent
b19542d062
commit
a785dece57
3 changed files with 21 additions and 1 deletions
|
@ -424,5 +424,20 @@ class TestMockingMagicMethods(unittest.TestCase):
|
|||
self.assertEqual(list(m), [])
|
||||
|
||||
|
||||
def test_divmod_and_rdivmod(self):
|
||||
m = MagicMock()
|
||||
self.assertIsInstance(divmod(5, m), MagicMock)
|
||||
m.__divmod__.return_value = (2, 1)
|
||||
self.assertEqual(divmod(m, 2), (2, 1))
|
||||
m = MagicMock()
|
||||
foo = divmod(2, m)
|
||||
self.assertIsInstance(foo, MagicMock)
|
||||
foo_direct = m.__divmod__(2)
|
||||
self.assertIsInstance(foo_direct, MagicMock)
|
||||
bar = divmod(m, 2)
|
||||
self.assertIsInstance(bar, MagicMock)
|
||||
bar_direct = m.__rdivmod__(2)
|
||||
self.assertIsInstance(bar_direct, MagicMock)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue