mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-62480: De-personalize "Coping with mutable arguments" section in unittest.mock examples (GH-141323)
(cherry picked from commit d527d3bf8b)
Co-authored-by: dereckduran <67027239+dereckduran@users.noreply.github.com>
This commit is contained in:
parent
eead7b43bc
commit
cace2a7af5
1 changed files with 2 additions and 2 deletions
|
|
@ -863,9 +863,9 @@ Here's one solution that uses the :attr:`~Mock.side_effect`
|
||||||
functionality. If you provide a ``side_effect`` function for a mock then
|
functionality. If you provide a ``side_effect`` function for a mock then
|
||||||
``side_effect`` will be called with the same args as the mock. This gives us an
|
``side_effect`` will be called with the same args as the mock. This gives us an
|
||||||
opportunity to copy the arguments and store them for later assertions. In this
|
opportunity to copy the arguments and store them for later assertions. In this
|
||||||
example I'm using *another* mock to store the arguments so that I can use the
|
example we're using *another* mock to store the arguments so that we can use the
|
||||||
mock methods for doing the assertion. Again a helper function sets this up for
|
mock methods for doing the assertion. Again a helper function sets this up for
|
||||||
me. ::
|
us. ::
|
||||||
|
|
||||||
>>> from copy import deepcopy
|
>>> from copy import deepcopy
|
||||||
>>> from unittest.mock import Mock, patch, DEFAULT
|
>>> from unittest.mock import Mock, patch, DEFAULT
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue