diff options
author | Georg Brandl <georg@python.org> | 2006-06-22 14:46:46 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2006-06-22 14:46:46 (GMT) |
commit | f57c54db034611d31539c28a5477737b8224ad09 (patch) | |
tree | bce1d6adb7d9385a903bcfee383f03b4f9315b15 /Lib | |
parent | c3f49ca558d2abe8f1f4d2eea0838463c34364c4 (diff) | |
download | cpython-f57c54db034611d31539c28a5477737b8224ad09.zip cpython-f57c54db034611d31539c28a5477737b8224ad09.tar.gz cpython-f57c54db034611d31539c28a5477737b8224ad09.tar.bz2 |
Test for correct compilation of try-except-finally stmt.
Test for correct lineno on list, tuple, dict literals.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_compiler.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_compiler.py b/Lib/test/test_compiler.py index 6fb20c8..17f181e 100644 --- a/Lib/test/test_compiler.py +++ b/Lib/test/test_compiler.py @@ -56,6 +56,15 @@ class CompilerTest(unittest.TestCase): 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 @@ a, b = 2, 3 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: |