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:
Kushal Das 2014-04-16 23:32:21 +05:30
parent c3ac9af6d0
commit 8c14534df6
4 changed files with 27 additions and 3 deletions

View file

@ -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