From: Elizabeth Uselton Date: Sun, 14 Jul 2019 20:53:09 +0000 (-0700) Subject: bpo-37555: Regression test demonstrating assert_has_calls not working with ANY and... X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b4c7d78c8e62c5eb8ec78de44934b1fb6b107826;p=thirdparty%2FPython%2Fcpython.git bpo-37555: Regression test demonstrating assert_has_calls not working with ANY and spec_set Co-authored-by: Neal Finne --- diff --git a/Lib/unittest/test/testmock/testhelpers.py b/Lib/unittest/test/testmock/testhelpers.py index 301bca430c13..49fffa38439f 100644 --- a/Lib/unittest/test/testmock/testhelpers.py +++ b/Lib/unittest/test/testmock/testhelpers.py @@ -63,7 +63,19 @@ class AnyTest(unittest.TestCase): ] self.assertEqual(expected, mock.mock_calls) self.assertEqual(mock.mock_calls, expected) + mock.assert_has_calls(expected) + def test_assert_has_calls_with_any_and_spec_set(self): + # This is a regression test for bpo-37555 + class Foo(object): + def __eq__(self, other): pass + def __ne__(self, other): pass + + mock = Mock(spec_set=Foo) + expected = [call(ANY)] + mock(Foo()) + + mock.assert_has_calls(expected) class CallTest(unittest.TestCase):