mirror of
https://github.com/python/cpython.git
synced 2025-07-24 03:35:53 +00:00
Closes Issue 21238: New keyword argument unsafe
to Mock.
It raises `AttributeError` incase of an attribute startswith assert or assret.
This commit is contained in:
parent
c3ac9af6d0
commit
8c14534df6
4 changed files with 27 additions and 3 deletions
|
@ -1187,6 +1187,17 @@ class MockTest(unittest.TestCase):
|
|||
m = mock.create_autospec(object(), name='sweet_func')
|
||||
self.assertIn('sweet_func', repr(m))
|
||||
|
||||
#Issue21238
|
||||
def test_mock_unsafe(self):
|
||||
m = Mock()
|
||||
with self.assertRaises(AttributeError):
|
||||
m.assert_foo_call()
|
||||
with self.assertRaises(AttributeError):
|
||||
m.assret_foo_call()
|
||||
m = Mock(unsafe=True)
|
||||
m.assert_foo_call()
|
||||
m.assret_foo_call()
|
||||
|
||||
def test_mock_add_spec(self):
|
||||
class _One(object):
|
||||
one = 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue