changeset 27786:4a7dc29bfad8

test-ctxmanager: fix Python 2.6 compatibility problem
author Bryan O'Sullivan <bryano@fb.com>
date Thu, 14 Jan 2016 09:31:03 -0800
parents ba427b51f1d8
children e6e34c4e3916
files tests/test-ctxmanager.py
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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')])