Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(250)

Unified Diff: Lib/test/test_compiler.py

Issue 53094: Multi with statement Base URL: http://svn.python.org/view/*checkout*/python/trunk/
Patch Set: Version after review by Benjamin Created 16 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/compiler/transformer.py ('k') | Lib/test/test_parser.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Lib/test/test_compiler.py
===================================================================
--- Lib/test/test_compiler.py (revision 72182)
+++ Lib/test/test_compiler.py (working copy)
@@ -165,6 +165,27 @@
exec c in dct
self.assertEquals(dct.get('result'), 1)
+ def testWithMult(self):
+ events = []
+ class Ctx:
+ def __init__(self, n):
+ self.n = n
+ def __enter__(self):
+ events.append(self.n)
+ def __exit__(self, *args):
+ pass
+ c = compiler.compile('from __future__ import with_statement\n'
+ 'def f():\n'
+ ' with Ctx(1) as tc, Ctx(2) as tc2:\n'
+ ' return 1\n'
+ 'result = f()',
+ '<string>',
+ 'exec' )
+ dct = {'Ctx': Ctx}
+ exec c in dct
+ self.assertEquals(dct.get('result'), 1)
+ self.assertEquals(events, [1, 2])
+
def testGlobal(self):
code = compiler.compile('global x\nx=1', '<string>', 'exec')
d1 = {'__builtins__': {}}
« no previous file with comments | « Lib/compiler/transformer.py ('k') | Lib/test/test_parser.py » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b