diff options
Diffstat (limited to 'Lib/unittest/test/testmock/testwith.py')
-rw-r--r-- | Lib/unittest/test/testmock/testwith.py | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/Lib/unittest/test/testmock/testwith.py b/Lib/unittest/test/testmock/testwith.py index ec4e540dcfd..37100b8c183 100644 --- a/Lib/unittest/test/testmock/testwith.py +++ b/Lib/unittest/test/testmock/testwith.py @@ -10,6 +10,8 @@ something = sentinel.Something something_else = sentinel.SomethingElse +class SampleException(Exception): pass + class WithTest(unittest.TestCase): @@ -20,14 +22,10 @@ class WithTest(unittest.TestCase): def test_with_statement_exception(self): - try: + with self.assertRaises(SampleException): with patch('%s.something' % __name__, sentinel.Something2): self.assertEqual(something, sentinel.Something2, "unpatched") - raise Exception('pow') - except Exception: - pass - else: - self.fail("patch swallowed exception") + raise SampleException() self.assertEqual(something, sentinel.Something) @@ -128,8 +126,7 @@ class WithTest(unittest.TestCase): def test_double_patch_instance_method(self): class C: - def f(self): - pass + def f(self): pass c = C() |