summaryrefslogtreecommitdiffstats
path: root/Doc/library/unittest.mock.rst
diff options
context:
space:
mode:
authorKushal Das <kushaldas@gmail.com>2014-04-16 18:02:21 (GMT)
committerKushal Das <kushaldas@gmail.com>2014-04-16 18:02:21 (GMT)
commit8c14534df6c7bd561fac31985fba60306e181265 (patch)
tree6a5b70b694cef522be062194b0d6953fb412ab3a /Doc/library/unittest.mock.rst
parentc3ac9af6d00ec9b5939a0ce31984113ddb9b0a9c (diff)
downloadcpython-8c14534df6c7bd561fac31985fba60306e181265.zip
cpython-8c14534df6c7bd561fac31985fba60306e181265.tar.gz
cpython-8c14534df6c7bd561fac31985fba60306e181265.tar.bz2
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 6d4b82b..e6ca908 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