Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
8ab1e513
Commit
8ab1e513
authored
Apr 07, 2013
by
Andrew Svetlov
Browse files
Options
Browse Files
Download
Plain Diff
Process DEFAULT values in mock side_effect that returns iterator.
Patch by Michael Ford.
parents
5cd72b7b
8b2cd75b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
0 deletions
+6
-0
Lib/unittest/mock.py
Lib/unittest/mock.py
+2
-0
Lib/unittest/test/testmock/testmock.py
Lib/unittest/test/testmock/testmock.py
+4
-0
No files found.
Lib/unittest/mock.py
View file @
8ab1e513
...
...
@@ -931,6 +931,8 @@ class CallableMixin(Base):
result
=
next
(
effect
)
if
_is_exception
(
result
):
raise
result
if
result
is
DEFAULT
:
result
=
self
.
return_value
return
result
ret_val
=
effect
(
*
args
,
**
kwargs
)
...
...
Lib/unittest/test/testmock/testmock.py
View file @
8ab1e513
...
...
@@ -978,6 +978,10 @@ class MockTest(unittest.TestCase):
self.assertRaises(StopIteration, mock)
self.assertIs(mock.side_effect, this_iter)
def test_side_effect_iterator_default(self):
mock = Mock(return_value=2)
mock.side_effect = iter([1, DEFAULT])
self.assertEqual([mock(), mock()], [1, 2])
def test_assert_has_calls_any_order(self):
mock = Mock()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment