summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/unittest/mock.py2
-rw-r--r--Lib/unittest/test/testmock/testmock.py4
2 files changed, 6 insertions, 0 deletions
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py
index 5a1db8a..dc5c033 100644
--- a/Lib/unittest/mock.py
+++ b/Lib/unittest/mock.py
@@ -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)
diff --git a/Lib/unittest/test/testmock/testmock.py b/Lib/unittest/test/testmock/testmock.py
index 475a826..127786c 100644
--- a/Lib/unittest/test/testmock/testmock.py
+++ b/Lib/unittest/test/testmock/testmock.py
@@ -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()