mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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:
parent
c3ac9af6d0
commit
8c14534df6
4 changed files with 27 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue