[Python-checkins] r47070 - python/trunk/Lib/test/test_compiler.py
georg.brandl
python-checkins at python.org
Thu Jun 22 16:46:46 CEST 2006
Author: georg.brandl
Date: Thu Jun 22 16:46:46 2006
New Revision: 47070
Modified:
python/trunk/Lib/test/test_compiler.py
Log:
Test for correct compilation of try-except-finally stmt.
Test for correct lineno on list, tuple, dict literals.
Modified: python/trunk/Lib/test/test_compiler.py
==============================================================================
--- python/trunk/Lib/test/test_compiler.py (original)
+++ python/trunk/Lib/test/test_compiler.py Thu Jun 22 16:46:46 2006
@@ -56,6 +56,15 @@
def testYieldExpr(self):
compiler.compile("def g(): yield\n\n", "<string>", "exec")
+ def testTryExceptFinally(self):
+ # Test that except and finally clauses in one try stmt are recognized
+ c = compiler.compile("try:\n 1/0\nexcept:\n e = 1\nfinally:\n f = 1",
+ "<string>", "exec")
+ dct = {}
+ exec c in dct
+ self.assertEquals(dct.get('e'), 1)
+ self.assertEquals(dct.get('f'), 1)
+
def testDefaultArgs(self):
self.assertRaises(SyntaxError, compiler.parse, "def foo(a=1, b): pass")
@@ -103,6 +112,12 @@
l = [(x, y) for x, y in zip(range(5), range(5,10))]
l[0]
l[3:4]
+d = {'a': 2}
+d = {}
+t = ()
+t = (1, 2)
+l = []
+l = [1, 2]
if l:
pass
else:
More information about the Python-checkins
mailing list