summaryrefslogtreecommitdiffstats
path: root/Lib/unittest/test
diff options
context:
space:
mode:
authorBerker Peksag <berker.peksag@gmail.com>2016-03-27 21:30:02 (GMT)
committerBerker Peksag <berker.peksag@gmail.com>2016-03-27 21:30:02 (GMT)
commitce913877e42b7fa03434c2e765ace891e0f5c4dc (patch)
tree368cf51d0228cb951d2410a8e62703cc32c11c64 /Lib/unittest/test
parentfa0f62d6ab3d4acf949bd0160bca16f0f973c323 (diff)
downloadcpython-ce913877e42b7fa03434c2e765ace891e0f5c4dc.zip
cpython-ce913877e42b7fa03434c2e765ace891e0f5c4dc.tar.gz
cpython-ce913877e42b7fa03434c2e765ace891e0f5c4dc.tar.bz2
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.
Diffstat (limited to 'Lib/unittest/test')
-rw-r--r--Lib/unittest/test/testmock/testmock.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/unittest/test/testmock/testmock.py b/Lib/unittest/test/testmock/testmock.py
index 2a6069f..03c95de 100644
--- a/Lib/unittest/test/testmock/testmock.py
+++ b/Lib/unittest/test/testmock/testmock.py
@@ -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