Fixes issue28380: unittest.mock Mock autospec functions now properly support

assert_called, assert_not_called, and assert_called_once.
This commit is contained in:
Gregory P. Smith 2016-10-06 14:31:23 -07:00
parent 0ebdd0776c
commit ac5084b6c7
3 changed files with 18 additions and 0 deletions

View file

@ -969,8 +969,14 @@ class PatchTest(unittest.TestCase):
def test_autospec_function(self):
@patch('%s.function' % __name__, autospec=True)
def test(mock):
function.assert_not_called()
self.assertRaises(AssertionError, function.assert_called)
self.assertRaises(AssertionError, function.assert_called_once)
function(1)
self.assertRaises(AssertionError, function.assert_not_called)
function.assert_called_with(1)
function.assert_called()
function.assert_called_once()
function(2, 3)
function.assert_called_with(2, 3)