Show More
@@ -55,21 +55,23 b' class test_ctxmanager(unittest.TestCase)' | |||
|
55 | 55 | def test_raise_on_enter(self): |
|
56 | 56 | trace = [] |
|
57 | 57 | addtrace = trace.append |
|
58 | with self.assertRaises(ctxerror): | |
|
58 | def go(): | |
|
59 | 59 | with ctxmanager(ctxmgr('a', addtrace), |
|
60 | 60 | lambda: raise_on_enter('b', addtrace)) as c: |
|
61 | 61 | c.enter() |
|
62 | 62 | addtrace('unreachable') |
|
63 | self.assertRaises(ctxerror, go) | |
|
63 | 64 | self.assertEqual(trace, [('enter', 'a'), ('raise', 'b'), ('exit', 'a')]) |
|
64 | 65 | |
|
65 | 66 | def test_raise_on_exit(self): |
|
66 | 67 | trace = [] |
|
67 | 68 | addtrace = trace.append |
|
68 | with self.assertRaises(ctxerror): | |
|
69 | def go(): | |
|
69 | 70 | with ctxmanager(ctxmgr('a', addtrace), |
|
70 | 71 | lambda: raise_on_exit('b', addtrace)) as c: |
|
71 | 72 | c.enter() |
|
72 | 73 | addtrace('running') |
|
74 | self.assertRaises(ctxerror, go) | |
|
73 | 75 | self.assertEqual(trace, [('enter', 'a'), ('enter', 'b'), 'running', |
|
74 | 76 | ('raise', 'b'), ('exit', 'a')]) |
|
75 | 77 |
General Comments 0
You need to be logged in to leave comments.
Login now