From b4c7d78c8e62c5eb8ec78de44934b1fb6b107826 Mon Sep 17 00:00:00 2001 From: Elizabeth Uselton Date: Sun, 14 Jul 2019 13:53:09 -0700 Subject: [PATCH] bpo-37555: Regression test demonstrating assert_has_calls not working with ANY and spec_set Co-authored-by: Neal Finne --- Lib/unittest/test/testmock/testhelpers.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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): -- 2.47.3