test-ctxmanager: fix Python 2.6 compatibility problem
authorBryan O'Sullivan <bryano@fb.com>
Thu, 14 Jan 2016 09:31:03 -0800
changeset 27786 4a7dc29bfad8
parent 27785 ba427b51f1d8
child 27787 e6e34c4e3916
test-ctxmanager: fix Python 2.6 compatibility problem
tests/test-ctxmanager.py
--- a/tests/test-ctxmanager.py	Thu Jan 14 09:31:01 2016 -0800
+++ b/tests/test-ctxmanager.py	Thu Jan 14 09:31:03 2016 -0800
@@ -55,21 +55,23 @@
     def test_raise_on_enter(self):
         trace = []
         addtrace = trace.append
-        with self.assertRaises(ctxerror):
+        def go():
             with ctxmanager(ctxmgr('a', addtrace),
                            lambda: raise_on_enter('b', addtrace)) as c:
                 c.enter()
                 addtrace('unreachable')
+        self.assertRaises(ctxerror, go)
         self.assertEqual(trace, [('enter', 'a'), ('raise', 'b'), ('exit', 'a')])
 
     def test_raise_on_exit(self):
         trace = []
         addtrace = trace.append
-        with self.assertRaises(ctxerror):
+        def go():
             with ctxmanager(ctxmgr('a', addtrace),
                            lambda: raise_on_exit('b', addtrace)) as c:
                 c.enter()
                 addtrace('running')
+        self.assertRaises(ctxerror, go)
         self.assertEqual(trace, [('enter', 'a'), ('enter', 'b'), 'running',
                                  ('raise', 'b'), ('exit', 'a')])