mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Fixes issue28380: unittest.mock Mock autospec functions now properly support
assert_called, assert_not_called, and assert_called_once.
This commit is contained in:
parent
0ebdd0776c
commit
ac5084b6c7
3 changed files with 18 additions and 0 deletions
|
@ -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)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue