diff options
Diffstat (limited to 'Lib/unittest/test')
-rw-r--r-- | Lib/unittest/test/testmock/testhelpers.py | 7 | ||||
-rw-r--r-- | Lib/unittest/test/testmock/testmagicmethods.py | 8 |
2 files changed, 15 insertions, 0 deletions
diff --git a/Lib/unittest/test/testmock/testhelpers.py b/Lib/unittest/test/testmock/testhelpers.py index 7a7145e..8bfb293 100644 --- a/Lib/unittest/test/testmock/testhelpers.py +++ b/Lib/unittest/test/testmock/testhelpers.py @@ -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): diff --git a/Lib/unittest/test/testmock/testmagicmethods.py b/Lib/unittest/test/testmock/testmagicmethods.py index bd52e25..2bcf088 100644 --- a/Lib/unittest/test/testmock/testmagicmethods.py +++ b/Lib/unittest/test/testmock/testmagicmethods.py @@ -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(): |