if delegated is None:
return self._mock_side_effect
sf = delegated.side_effect
- if sf is not None and not callable(sf) and not isinstance(sf, _MockIter):
+ if (sf is not None and not callable(sf)
+ and not isinstance(sf, _MockIter) and not _is_exception(sf)):
sf = _MockIter(sf)
delegated.side_effect = sf
return sf
self.assertEqual([mock(), mock(), mock()], [3, 2, 1],
"callable side effect not used correctly")
+ def test_autospec_side_effect_exception(self):
+ # Test for issue 23661
+ def f():
+ pass
+
+ mock = create_autospec(f)
+ mock.side_effect = ValueError('Bazinga!')
+ self.assertRaisesRegex(ValueError, 'Bazinga!', mock)
+
@unittest.skipUnless('java' in sys.platform,
'This test only applies to Jython')
def test_java_exception_side_effect(self):
Gennadiy Zlobin
Doug Zongker
Peter Ã…strand
+Ignacio Rossi
for patterns that starts with capturing groups. Fast searching optimization
now can't be disabled at compile time.
+- Issue #23661: unittest.mock side_effects can now be exceptions again. This
+ was a regression vs Python 3.4. Patch from Ignacio Rossi
+
What's New in Python 3.5.0 beta 4?
==================================