summaryrefslogtreecommitdiff
path: root/Doc/library/unittest.mock.rst
diff options
context:
space:
mode:
authorKushal Das <kushaldas@gmail.com>2014-04-16 23:32:21 +0530
committerKushal Das <kushaldas@gmail.com>2014-04-16 23:32:21 +0530
commita82ff32cce73e2a249edae07fadab02d2ff9190f (patch)
treec9d33ab06a72c20e6dd51a16c0deef86f39f9c5b /Doc/library/unittest.mock.rst
parent508ad55701f2440d339de8b4321dff59156b140b (diff)
downloadcpython-a82ff32cce73e2a249edae07fadab02d2ff9190f.tar.gz
Closes Issue 21238: New keyword argument `unsafe` to Mock.
It raises `AttributeError` incase of an attribute startswith assert or assret.
Diffstat (limited to 'Doc/library/unittest.mock.rst')
-rw-r--r--Doc/library/unittest.mock.rst8
1 files changed, 7 insertions, 1 deletions
diff --git a/Doc/library/unittest.mock.rst b/Doc/library/unittest.mock.rst
index 6d4b82bf0d..e6ca908816 100644
--- a/Doc/library/unittest.mock.rst
+++ b/Doc/library/unittest.mock.rst
@@ -198,7 +198,7 @@ a `MagicMock` for you. You can specify an alternative class of `Mock` using
the `new_callable` argument to `patch`.
-.. class:: Mock(spec=None, side_effect=None, return_value=DEFAULT, wraps=None, name=None, spec_set=None, **kwargs)
+.. class:: Mock(spec=None, side_effect=None, return_value=DEFAULT, wraps=None, name=None, spec_set=None, unsafe=False, **kwargs)
Create a new `Mock` object. `Mock` takes several optional arguments
that specify the behaviour of the Mock object:
@@ -235,6 +235,12 @@ the `new_callable` argument to `patch`.
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 `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