mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Fix exception when calling reset_mock on a mock created with autospec
This commit is contained in:
parent
afc0c77b42
commit
75963643b1
3 changed files with 18 additions and 0 deletions
|
@ -355,6 +355,13 @@ class SpecSignatureTest(unittest.TestCase):
|
|||
self.assertEqual(mock(), 'foo')
|
||||
|
||||
|
||||
def test_autospec_reset_mock(self):
|
||||
m = create_autospec(int)
|
||||
int(m)
|
||||
m.reset_mock()
|
||||
self.assertEqual(m.__int__.call_count, 0)
|
||||
|
||||
|
||||
def test_mocking_unbound_methods(self):
|
||||
class Foo(object):
|
||||
def foo(self, foo):
|
||||
|
|
|
@ -345,6 +345,14 @@ class TestMockingMagicMethods(unittest.TestCase):
|
|||
self.assertEqual(mock[1][2][3], 3)
|
||||
|
||||
|
||||
def test_magic_method_reset_mock(self):
|
||||
mock = MagicMock()
|
||||
str(mock)
|
||||
self.assertTrue(mock.__str__.called)
|
||||
mock.reset_mock()
|
||||
self.assertFalse(mock.__str__.called)
|
||||
|
||||
|
||||
def test_dir(self):
|
||||
# overriding the default implementation
|
||||
for mock in Mock(), MagicMock():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue