mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-24758: Improve the error msg for unittest.mock.Mock()'s unsafe mode (#12991)
* bpo-24758: Improve the error msg for unittest.mock.Mock()'s unsafe mode * Make the requested changes.
This commit is contained in:
parent
6bd81734de
commit
b9b08cd948
2 changed files with 5 additions and 3 deletions
|
@ -1453,9 +1453,10 @@ class MockTest(unittest.TestCase):
|
|||
#Issue21238
|
||||
def test_mock_unsafe(self):
|
||||
m = Mock()
|
||||
with self.assertRaises(AttributeError):
|
||||
msg = "Attributes cannot start with 'assert' or 'assret'"
|
||||
with self.assertRaisesRegex(AttributeError, msg):
|
||||
m.assert_foo_call()
|
||||
with self.assertRaises(AttributeError):
|
||||
with self.assertRaisesRegex(AttributeError, msg):
|
||||
m.assret_foo_call()
|
||||
m = Mock(unsafe=True)
|
||||
m.assert_foo_call()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue