# HG changeset patch # User Bryan O'Sullivan # Date 2016-01-14 17:31:03 # Node ID 4a7dc29bfad835755ad7b58dd80e882d7aea1e9e # Parent ba427b51f1d8733139066fedef772691769beeef test-ctxmanager: fix Python 2.6 compatibility problem diff --git a/tests/test-ctxmanager.py b/tests/test-ctxmanager.py --- a/tests/test-ctxmanager.py +++ b/tests/test-ctxmanager.py @@ -55,21 +55,23 @@ class test_ctxmanager(unittest.TestCase) 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')])