mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
Minor docstring / docs corrections for unittest.mock
This commit is contained in:
parent
656319e58d
commit
0682a0c0a9
3 changed files with 11 additions and 11 deletions
|
@ -99,7 +99,7 @@ by looking at the return value of the mocked class.
|
||||||
In the example below we have a function `some_function` that instantiates `Foo`
|
In the example below we have a function `some_function` that instantiates `Foo`
|
||||||
and calls a method on it. The call to `patch` replaces the class `Foo` with a
|
and calls a method on it. The call to `patch` replaces the class `Foo` with a
|
||||||
mock. The `Foo` instance is the result of calling the mock, so it is configured
|
mock. The `Foo` instance is the result of calling the mock, so it is configured
|
||||||
by modify the mock :attr:`~Mock.return_value`.
|
by modifying the mock :attr:`~Mock.return_value`.
|
||||||
|
|
||||||
>>> def some_function():
|
>>> def some_function():
|
||||||
... instance = module.Foo()
|
... instance = module.Foo()
|
||||||
|
|
|
@ -236,10 +236,10 @@ the `new_callable` argument to `patch`.
|
||||||
|
|
||||||
* `wraps`: Item for the mock object to wrap. If `wraps` is not None then
|
* `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
|
calling the Mock will pass the call through to the wrapped object
|
||||||
(returning the real result and ignoring `return_value`). Attribute access
|
(returning the real result). Attribute access on the mock will return a
|
||||||
on the mock will return a Mock object that wraps the corresponding
|
Mock object that wraps the corresponding attribute of the wrapped
|
||||||
attribute of the wrapped object (so attempting to access an attribute
|
object (so attempting to access an attribute that doesn't exist will
|
||||||
that doesn't exist will raise an `AttributeError`).
|
raise an `AttributeError`).
|
||||||
|
|
||||||
If the mock has an explicit `return_value` set then calls are not passed
|
If the mock has an explicit `return_value` set then calls are not passed
|
||||||
to the wrapped object and the `return_value` is returned instead.
|
to the wrapped object and the `return_value` is returned instead.
|
||||||
|
|
|
@ -941,12 +941,12 @@ class Mock(CallableMixin, NonCallableMock):
|
||||||
this is a new Mock (created on first access). See the
|
this is a new Mock (created on first access). See the
|
||||||
`return_value` attribute.
|
`return_value` attribute.
|
||||||
|
|
||||||
* `wraps`: Item for the mock object to wrap. If `wraps` is not None
|
* `wraps`: Item for the mock object to wrap. If `wraps` is not None then
|
||||||
then calling the Mock will pass the call through to the wrapped object
|
calling the Mock will pass the call through to the wrapped object
|
||||||
(returning the real result and ignoring `return_value`). Attribute
|
(returning the real result). Attribute access on the mock will return a
|
||||||
access on the mock will return a Mock object that wraps the corresponding
|
Mock object that wraps the corresponding attribute of the wrapped object
|
||||||
attribute of the wrapped object (so attempting to access an attribute that
|
(so attempting to access an attribute that doesn't exist will raise an
|
||||||
doesn't exist will raise an `AttributeError`).
|
`AttributeError`).
|
||||||
|
|
||||||
If the mock has an explicit `return_value` set then calls are not passed
|
If the mock has an explicit `return_value` set then calls are not passed
|
||||||
to the wrapped object and the `return_value` is returned instead.
|
to the wrapped object and the `return_value` is returned instead.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue