diff -r 06600287f11f Doc/library/unittest.mock.rst --- a/Doc/library/unittest.mock.rst Fri Jul 17 16:48:48 2015 -0700 +++ b/Doc/library/unittest.mock.rst Sat Jul 18 16:44:55 2015 -0700 @@ -228,22 +228,22 @@ the *new_callable* argument to :func:`pa If *side_effect* is an iterable then each call to the mock will return the next value from the iterable. A *side_effect* can be cleared by setting it to ``None``. * *return_value*: The value returned when the mock is called. By default this is a new Mock (created on first access). See the :attr:`return_value` attribute. - * *unsafe*: By default if any attribute starts with *assert* or - *assret* will raise an :exc:`AttributeError`. Passing ``unsafe=True`` + * *unsafe*: By default if any attribute starts with *assert* + it will raise an :exc:`AttributeError`. Passing ``unsafe=True`` will allow access to these attributes. .. versionadded:: 3.5 * *wraps*: Item for the mock object to wrap. If *wraps* is not None then calling the Mock will pass the call through to the wrapped object (returning the real result). Attribute access on the mock will return a Mock object that wraps the corresponding attribute of the wrapped object (so attempting to access an attribute that doesn't exist will raise an :exc:`AttributeError`). diff -r 06600287f11f Lib/unittest/mock.py --- a/Lib/unittest/mock.py Fri Jul 17 16:48:48 2015 -0700 +++ b/Lib/unittest/mock.py Sat Jul 18 16:44:55 2015 -0700 @@ -572,21 +572,21 @@ class NonCallableMock(Base): def __getattr__(self, name): if name in {'_mock_methods', '_mock_unsafe'}: raise AttributeError(name) elif self._mock_methods is not None: if name not in self._mock_methods or name in _all_magics: raise AttributeError("Mock object has no attribute %r" % name) elif _is_magic(name): raise AttributeError(name) if not self._mock_unsafe: - if name.startswith(('assert', 'assret')): + if name.startswith('assert'): raise AttributeError(name) result = self._mock_children.get(name) if result is _deleted: raise AttributeError(name) elif result is None: wraps = None if self._mock_wraps is not None: # XXXX should we get the attribute without triggering code # execution? diff -r 06600287f11f Lib/unittest/test/testmock/testmock.py --- a/Lib/unittest/test/testmock/testmock.py Fri Jul 17 16:48:48 2015 -0700 +++ b/Lib/unittest/test/testmock/testmock.py Sat Jul 18 16:44:55 2015 -0700 @@ -1197,22 +1197,20 @@ class MockTest(unittest.TestCase): #Issue21222 def test_create_autospec_with_name(self): 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() #Issue21262 def test_assert_not_called(self): m = Mock() m.hello.assert_not_called() m.hello() with self.assertRaises(AssertionError): diff -r 06600287f11f Misc/NEWS --- a/Misc/NEWS Fri Jul 17 16:48:48 2015 -0700 +++ b/Misc/NEWS Sat Jul 18 16:44:55 2015 -0700 @@ -30,20 +30,22 @@ Library - Issue #24608: chunk.Chunk.read() now always returns bytes, not str. - Issue #18684: Fixed reading out of the buffer in the re module. - Issue #24259: tarfile now raises a ReadError if an archive is truncated inside a data segment. - Issue #15014: SMTP.auth() and SMTP.login() now support RFC 4954's optional initial-response argument to the SMTP AUTH command. +- Issue #24656: `unsafe` keyword to Mock only raises `AttributeError` for + attributes that start with assert, not assret. What's New in Python 3.5.0 beta 3? ================================== Release date: 2015-07-05 Core and Builtins ----------------- - Issue #24467: Fixed possible buffer over-read in bytearray. The bytearray