annotate Lib/test/test_codeop.py @ 58765:2ba7677bfa95 legacy-trunk

testCopysign was defined twice in test_math; combine the definitions
author Mark Dickinson <dickinsm@gmail.com>
date Sat, 06 Feb 2010 23:11:25 +0000
parents 89f42938d5cc
children 614c84670c63
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18878
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
1 """
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
2 Test cases for codeop.py
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
3 Nick Mathewson
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
4 """
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
5 import unittest
29145
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
6 from test.test_support import run_unittest, is_jython
18878
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
7
27878
be7683a6f521 - Finally fixed the bug in compile() and exec where a string ending
Guido van Rossum <guido@python.org>
parents: 24364
diff changeset
8 from codeop import compile_command, PyCF_DONT_IMPLY_DEDENT
18878
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
9
29145
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
10 if is_jython:
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
11 import sys
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
12 import cStringIO
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
13
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
14 def unify_callables(d):
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
15 for n,v in d.items():
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
16 if callable(v):
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
17 d[n] = callable
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
18 return d
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
19
18878
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
20 class CodeopTests(unittest.TestCase):
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
21
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
22 def assertValid(self, str, symbol='single'):
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
23 '''succeed iff str is a valid piece of code'''
29145
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
24 if is_jython:
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
25 code = compile_command(str, "<input>", symbol)
55002
6768b2350c57 convert usage of fail* to assert*
Benjamin Peterson <benjamin@python.org>
parents: 29488
diff changeset
26 self.assertTrue(code)
29145
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
27 if symbol == "single":
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
28 d,r = {},{}
29151
8be9a316eb9d minor fix, jython-only. Don't asssume stdout to save is the ur-stdout.
Samuele Pedroni <pedronis@openend.se>
parents: 29145
diff changeset
29 saved_stdout = sys.stdout
29145
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
30 sys.stdout = cStringIO.StringIO()
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
31 try:
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
32 exec code in d
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
33 exec compile(str,"<input>","single") in r
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
34 finally:
29151
8be9a316eb9d minor fix, jython-only. Don't asssume stdout to save is the ur-stdout.
Samuele Pedroni <pedronis@openend.se>
parents: 29145
diff changeset
35 sys.stdout = saved_stdout
29145
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
36 elif symbol == 'eval':
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
37 ctx = {'a': 2}
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
38 d = { 'value': eval(code,ctx) }
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
39 r = { 'value': eval(str,ctx) }
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
40 self.assertEquals(unify_callables(r),unify_callables(d))
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
41 else:
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
42 expected = compile(str, "<input>", symbol, PyCF_DONT_IMPLY_DEDENT)
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
43 self.assertEquals( compile_command(str, "<input>", symbol), expected)
18878
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
44
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
45 def assertIncomplete(self, str, symbol='single'):
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
46 '''succeed iff str is the start of a valid piece of code'''
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
47 self.assertEquals( compile_command(str, symbol=symbol), None)
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
48
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
49 def assertInvalid(self, str, symbol='single', is_syntax=1):
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
50 '''succeed iff str is the start of an invalid piece of code'''
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
51 try:
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
52 compile_command(str,symbol=symbol)
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
53 self.fail("No exception thrown for invalid code")
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
54 except SyntaxError:
55002
6768b2350c57 convert usage of fail* to assert*
Benjamin Peterson <benjamin@python.org>
parents: 29488
diff changeset
55 self.assertTrue(is_syntax)
18878
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
56 except OverflowError:
55002
6768b2350c57 convert usage of fail* to assert*
Benjamin Peterson <benjamin@python.org>
parents: 29488
diff changeset
57 self.assertTrue(not is_syntax)
18878
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
58
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
59 def test_valid(self):
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
60 av = self.assertValid
29145
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
61
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
62 # special case
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
63 if not is_jython:
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
64 self.assertEquals(compile_command(""),
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
65 compile("pass", "<input>", 'single',
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
66 PyCF_DONT_IMPLY_DEDENT))
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
67 self.assertEquals(compile_command("\n"),
29488
5143cfe7cc75 Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 29151
diff changeset
68 compile("pass", "<input>", 'single',
29145
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
69 PyCF_DONT_IMPLY_DEDENT))
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
70 else:
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
71 av("")
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
72 av("\n")
29488
5143cfe7cc75 Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 29151
diff changeset
73
29145
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
74 av("a = 1")
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
75 av("\na = 1")
18878
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
76 av("a = 1\n")
29145
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
77 av("a = 1\n\n")
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
78 av("\n\na = 1\n\n")
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
79
18878
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
80 av("def x():\n pass\n")
29145
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
81 av("if 1:\n pass\n")
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
82
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
83 av("\n\nif 1: pass\n")
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
84 av("\n\nif 1: pass\n\n")
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
85
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
86 av("def x():\n\n pass\n")
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
87 av("def x():\n pass\n \n")
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
88 av("def x():\n pass\n \n")
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
89
18878
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
90 av("pass\n")
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
91 av("3**3\n")
29145
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
92
18878
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
93 av("if 9==3:\n pass\nelse:\n pass\n")
29145
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
94 av("if 1:\n pass\n if 1:\n pass\n else:\n pass\n")
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
95
18878
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
96 av("#a\n#b\na = 3\n")
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
97 av("#a\n\n \na=3\n")
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
98 av("a=3\n\n")
29145
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
99 av("a = 9+ \\\n3")
18878
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
100
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
101 av("3**3","eval")
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
102 av("(lambda z: \n z**3)","eval")
29145
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
103
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
104 av("9+ \\\n3","eval")
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
105 av("9+ \\\n3\n","eval")
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
106
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
107 av("\n\na**3","eval")
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
108 av("\n \na**3","eval")
18878
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
109 av("#a\n#b\na**3","eval")
19119
600a9a2b7a18 Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 18878
diff changeset
110
55528
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
111 av("\n\na = 1\n\n")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
112 av("\n\nif 1: a=1\n\n")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
113
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
114 av("if 1:\n pass\n if 1:\n pass\n else:\n pass\n")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
115 av("#a\n\n \na=3\n\n")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
116
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
117 av("\n\na**3","eval")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
118 av("\n \na**3","eval")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
119 av("#a\n#b\na**3","eval")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
120
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
121 av("def f():\n try: pass\n finally: [x for x in (1,2)]\n")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
122 av("def f():\n pass\n#foo\n")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
123 av("@a.b.c\ndef f():\n pass\n")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
124
18878
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
125 def test_incomplete(self):
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
126 ai = self.assertIncomplete
29145
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
127
18878
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
128 ai("(a **")
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
129 ai("(a,b,")
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
130 ai("(a,b,(")
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
131 ai("(a,b,(")
29145
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
132 ai("a = (")
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
133 ai("a = {")
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
134 ai("b + {")
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
135
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
136 ai("if 9==3:\n pass\nelse:")
18878
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
137 ai("if 9==3:\n pass\nelse:\n")
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
138 ai("if 9==3:\n pass\nelse:\n pass")
29145
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
139 ai("if 1:")
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
140 ai("if 1:\n")
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
141 ai("if 1:\n pass\n if 1:\n pass\n else:")
29488
5143cfe7cc75 Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 29151
diff changeset
142 ai("if 1:\n pass\n if 1:\n pass\n else:\n")
5143cfe7cc75 Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 29151
diff changeset
143 ai("if 1:\n pass\n if 1:\n pass\n else:\n pass")
5143cfe7cc75 Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 29151
diff changeset
144
29145
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
145 ai("def x():")
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
146 ai("def x():\n")
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
147 ai("def x():\n\n")
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
148
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
149 ai("def x():\n pass")
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
150 ai("def x():\n pass\n ")
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
151 ai("def x():\n pass\n ")
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
152 ai("\n\ndef x():\n pass")
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
153
18878
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
154 ai("a = 9+ \\")
29145
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
155 ai("a = 'a\\")
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
156 ai("a = '''xy")
19119
600a9a2b7a18 Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 18878
diff changeset
157
29145
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
158 ai("","eval")
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
159 ai("\n","eval")
18878
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
160 ai("(","eval")
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
161 ai("(\n\n\n","eval")
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
162 ai("(9+","eval")
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
163 ai("9+ \\","eval")
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
164 ai("lambda z: \\","eval")
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
165
55528
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
166 ai("if True:\n if True:\n if True: \n")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
167
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
168 ai("@a(")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
169 ai("@a(b")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
170 ai("@a(b,")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
171 ai("@a(b,c")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
172 ai("@a(b,c,")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
173
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
174 ai("from a import (")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
175 ai("from a import (b")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
176 ai("from a import (b,")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
177 ai("from a import (b,c")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
178 ai("from a import (b,c,")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
179
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
180 ai("[");
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
181 ai("[a");
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
182 ai("[a,");
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
183 ai("[a,b");
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
184 ai("[a,b,");
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
185
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
186 ai("{");
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
187 ai("{a");
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
188 ai("{a:");
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
189 ai("{a:b");
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
190 ai("{a:b,");
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
191 ai("{a:b,c");
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
192 ai("{a:b,c:");
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
193 ai("{a:b,c:d");
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
194 ai("{a:b,c:d,");
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
195
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
196 ai("a(")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
197 ai("a(b")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
198 ai("a(b,")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
199 ai("a(b,c")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
200 ai("a(b,c,")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
201
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
202 ai("a[")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
203 ai("a[b")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
204 ai("a[b,")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
205 ai("a[b:")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
206 ai("a[b:c")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
207 ai("a[b:c:")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
208 ai("a[b:c:d")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
209
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
210 ai("def a(")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
211 ai("def a(b")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
212 ai("def a(b,")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
213 ai("def a(b,c")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
214 ai("def a(b,c,")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
215
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
216 ai("(")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
217 ai("(a")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
218 ai("(a,")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
219 ai("(a,b")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
220 ai("(a,b,")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
221
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
222 ai("if a:\n pass\nelif b:")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
223 ai("if a:\n pass\nelif b:\n pass\nelse:")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
224
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
225 ai("while a:")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
226 ai("while a:\n pass\nelse:")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
227
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
228 ai("for a in b:")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
229 ai("for a in b:\n pass\nelse:")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
230
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
231 ai("try:")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
232 ai("try:\n pass\nexcept:")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
233 ai("try:\n pass\nfinally:")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
234 ai("try:\n pass\nexcept:\n pass\nfinally:")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
235
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
236 ai("with a:")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
237 ai("with a as b:")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
238
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
239 ai("class a:")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
240 ai("class a(")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
241 ai("class a(b")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
242 ai("class a(b,")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
243 ai("class a():")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
244
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
245 ai("[x for")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
246 ai("[x for x in")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
247 ai("[x for x in (")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
248
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
249 ai("(x for")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
250 ai("(x for x in")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
251 ai("(x for x in (")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
252
18878
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
253 def test_invalid(self):
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
254 ai = self.assertInvalid
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
255 ai("a b")
29145
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
256
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
257 ai("a @")
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
258 ai("a b @")
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
259 ai("a ** @")
29488
5143cfe7cc75 Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 29151
diff changeset
260
18878
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
261 ai("a = ")
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
262 ai("a = 9 +")
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
263
29145
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
264 ai("def x():\n\npass\n")
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
265
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
266 ai("\n\n if 1: pass\n\npass")
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
267
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
268 ai("a = 9+ \\\n")
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
269 ai("a = 'a\\ ")
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
270 ai("a = 'a\\\n")
e6e100efbc7d beefed up version: jython support, covers now fixed differences between CPython/Jython.
Samuele Pedroni <pedronis@openend.se>
parents: 27878
diff changeset
271
18878
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
272 ai("a = 1","eval")
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
273 ai("a = (","eval")
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
274 ai("]","eval")
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
275 ai("())","eval")
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
276 ai("[}","eval")
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
277 ai("9+","eval")
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
278 ai("lambda z:","eval")
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
279 ai("a b","eval")
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
280
55528
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
281 ai("return 2.3")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
282 ai("if (a == 1 and b = 2): pass")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
283
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
284 ai("del 1")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
285 ai("del ()")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
286 ai("del (1,)")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
287 ai("del [1]")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
288 ai("del '1'")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
289
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
290 ai("[i for i in range(10)] = (1, 2, 3)")
46e46a0e622e Adding tests derived from the Jython project. These are primarily tests of
Frank Wierzbicki <fwierzbicki@gmail.com>
parents: 55002
diff changeset
291
18878
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
292 def test_filename(self):
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
293 self.assertEquals(compile_command("a = 1\n", "abc").co_filename,
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
294 compile("a = 1\n", "abc", 'single').co_filename)
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
295 self.assertNotEquals(compile_command("a = 1\n", "abc").co_filename,
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
296 compile("a = 1\n", "def", 'single').co_filename)
4d9ebeedbd04 Patch #442866: Tests for codeop.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff changeset
297
20013
e3184e46303b Change the PyUnit-based tests to use the test_main() approach. This
Fred Drake <fdrake@acm.org>
parents: 19119
diff changeset
298
e3184e46303b Change the PyUnit-based tests to use the test_main() approach. This
Fred Drake <fdrake@acm.org>
parents: 19119
diff changeset
299 def test_main():
e3184e46303b Change the PyUnit-based tests to use the test_main() approach. This
Fred Drake <fdrake@acm.org>
parents: 19119
diff changeset
300 run_unittest(CodeopTests)
e3184e46303b Change the PyUnit-based tests to use the test_main() approach. This
Fred Drake <fdrake@acm.org>
parents: 19119
diff changeset
301
e3184e46303b Change the PyUnit-based tests to use the test_main() approach. This
Fred Drake <fdrake@acm.org>
parents: 19119
diff changeset
302
e3184e46303b Change the PyUnit-based tests to use the test_main() approach. This
Fred Drake <fdrake@acm.org>
parents: 19119
diff changeset
303 if __name__ == "__main__":
e3184e46303b Change the PyUnit-based tests to use the test_main() approach. This
Fred Drake <fdrake@acm.org>
parents: 19119
diff changeset
304 test_main()