[Python-checkins] cpython (3.4): Issue #22823: Fixed an output of sets in examples.
serhiy.storchaka
python-checkins at python.org
Thu Dec 11 09:36:22 CET 2014
https://hg.python.org/cpython/rev/86a694781bee
changeset: 93828:86a694781bee
branch: 3.4
parent: 93825:1ace87a5e10c
user: Serhiy Storchaka <storchaka at gmail.com>
date: Thu Dec 11 10:30:21 2014 +0200
summary:
Issue #22823: Fixed an output of sets in examples.
files:
Doc/library/unittest.mock-examples.rst | 24 +++++++-------
1 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/Doc/library/unittest.mock-examples.rst b/Doc/library/unittest.mock-examples.rst
--- a/Doc/library/unittest.mock-examples.rst
+++ b/Doc/library/unittest.mock-examples.rst
@@ -756,16 +756,16 @@
what happens:
>>> with patch('mymodule.frob') as mock_frob:
- ... val = set([6])
+ ... val = {6}
... mymodule.grob(val)
...
>>> val
- set([])
- >>> mock_frob.assert_called_with(set([6]))
+ set()
+ >>> mock_frob.assert_called_with({6})
Traceback (most recent call last):
...
- AssertionError: Expected: ((set([6]),), {})
- Called with: ((set([]),), {})
+ AssertionError: Expected: (({6},), {})
+ Called with: ((set(),), {})
One possibility would be for mock to copy the arguments you pass in. This
could then cause problems if you do assertions that rely on object identity
@@ -793,12 +793,12 @@
...
>>> with patch('mymodule.frob') as mock_frob:
... new_mock = copy_call_args(mock_frob)
- ... val = set([6])
+ ... val = {6}
... mymodule.grob(val)
...
- >>> new_mock.assert_called_with(set([6]))
+ >>> new_mock.assert_called_with({6})
>>> new_mock.call_args
- call(set([6]))
+ call({6})
``copy_call_args`` is called with the mock that will be called. It returns a new
mock that we do the assertion on. The ``side_effect`` function makes a copy of
@@ -811,10 +811,10 @@
checking inside a ``side_effect`` function.
>>> def side_effect(arg):
- ... assert arg == set([6])
+ ... assert arg == {6}
...
>>> mock = Mock(side_effect=side_effect)
- >>> mock(set([6]))
+ >>> mock({6})
>>> mock(set())
Traceback (most recent call last):
...
@@ -839,8 +839,8 @@
>>> c.assert_called_with(arg)
Traceback (most recent call last):
...
- AssertionError: Expected call: mock(set([1]))
- Actual call: mock(set([]))
+ AssertionError: Expected call: mock({1})
+ Actual call: mock(set())
>>> c.foo
<CopyingMock name='mock.foo' id='...'>
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list