mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +00:00
Issue #25195: Fix a regression in mock.MagicMock
_Call is a subclass of tuple (changeset 3603bae63c13 only works for classes) so we need to implement __ne__ ourselves. Patch by Andrew Plummer.
This commit is contained in:
commit
5a6c018b57
3 changed files with 24 additions and 0 deletions
|
@ -304,6 +304,17 @@ class MockTest(unittest.TestCase):
|
|||
# an exception. See issue 24857.
|
||||
self.assertFalse(mock.call_args == "a long sequence")
|
||||
|
||||
|
||||
def test_calls_equal_with_any(self):
|
||||
call1 = mock.call(mock.MagicMock())
|
||||
call2 = mock.call(mock.ANY)
|
||||
|
||||
# Check that equality and non-equality is consistent even when
|
||||
# comparing with mock.ANY
|
||||
self.assertTrue(call1 == call2)
|
||||
self.assertFalse(call1 != call2)
|
||||
|
||||
|
||||
def test_assert_called_with(self):
|
||||
mock = Mock()
|
||||
mock()
|
||||
|
@ -319,6 +330,12 @@ class MockTest(unittest.TestCase):
|
|||
mock.assert_called_with(1, 2, 3, a='fish', b='nothing')
|
||||
|
||||
|
||||
def test_assert_called_with_any(self):
|
||||
m = MagicMock()
|
||||
m(MagicMock())
|
||||
m.assert_called_with(mock.ANY)
|
||||
|
||||
|
||||
def test_assert_called_with_function_spec(self):
|
||||
def f(a, b, c, d=None):
|
||||
pass
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue