summaryrefslogtreecommitdiffstats
path: root/Lib/unittest/test/testmock/testmock.py
diff options
context:
space:
mode:
authorRobert Collins <rbtcollins@hp.com>2015-07-14 01:51:40 (GMT)
committerRobert Collins <rbtcollins@hp.com>2015-07-14 01:51:40 (GMT)
commitf58f88c4c7df1827a31457da8dbcacd127613ade (patch)
tree20558bf0614bd80cb714b3007654ba6832e1257b /Lib/unittest/test/testmock/testmock.py
parent47066ee3db59e39d3567abf918d1fa621f9bca99 (diff)
downloadcpython-f58f88c4c7df1827a31457da8dbcacd127613ade.zip
cpython-f58f88c4c7df1827a31457da8dbcacd127613ade.tar.gz
cpython-f58f88c4c7df1827a31457da8dbcacd127613ade.tar.bz2
Issue #23661: unittest.mock side_effects can now be exceptions again.
This was a regression vs Python 3.4. Patch from Ignacio Rossi
Diffstat (limited to 'Lib/unittest/test/testmock/testmock.py')
-rw-r--r--Lib/unittest/test/testmock/testmock.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/unittest/test/testmock/testmock.py b/Lib/unittest/test/testmock/testmock.py
index 3a104cb..f4a723d 100644
--- a/Lib/unittest/test/testmock/testmock.py
+++ b/Lib/unittest/test/testmock/testmock.py
@@ -173,6 +173,15 @@ class MockTest(unittest.TestCase):
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):