blob: 6acd1e7eed9d50664a9aebd72f34ad69bf7ec6dc [file] [log] [blame]
Fred Drake79ca79d2000-08-21 22:30:53 +00001import parser
Benjamin Petersoneeed0c72008-11-03 15:18:30 +00002import os
Fred Drake58422e52001-06-04 03:56:24 +00003import unittest
Martin v. Löwis66e26632008-03-18 13:16:05 +00004import sys
Barry Warsaw04f357c2002-07-23 19:04:11 +00005from test import test_support
Fred Drake79ca79d2000-08-21 22:30:53 +00006
7#
8# First, we test that we can generate trees from valid source fragments,
9# and that these valid trees are indeed allowed by the tree-loading side
10# of the parser module.
11#
12
Fred Drake58422e52001-06-04 03:56:24 +000013class RoundtripLegalSyntaxTestCase(unittest.TestCase):
Guido van Rossum32c2ae72002-08-22 19:45:32 +000014
Fred Drake58422e52001-06-04 03:56:24 +000015 def roundtrip(self, f, s):
16 st1 = f(s)
17 t = st1.totuple()
18 try:
Fred Drake6e4f2c02001-07-17 19:33:25 +000019 st2 = parser.sequence2st(t)
Anthony Baxterc2a5a632004-08-02 06:10:11 +000020 except parser.ParserError, why:
21 self.fail("could not roundtrip %r: %s" % (s, why))
Fred Drake79ca79d2000-08-21 22:30:53 +000022
Fred Drake58422e52001-06-04 03:56:24 +000023 self.assertEquals(t, st2.totuple(),
24 "could not re-generate syntax tree")
Fred Drake28f739a2000-08-25 22:42:40 +000025
Fred Drake58422e52001-06-04 03:56:24 +000026 def check_expr(self, s):
27 self.roundtrip(parser.expr, s)
Fred Drake28f739a2000-08-25 22:42:40 +000028
Benjamin Peterson084ce7a2008-10-31 02:26:20 +000029 def test_flags_passed(self):
30 # The unicode literals flags has to be passed from the paser to AST
31 # generation.
32 suite = parser.suite("from __future__ import unicode_literals; x = ''")
33 code = suite.compile()
34 scope = {}
35 exec code in scope
36 self.assertTrue(isinstance(scope["x"], unicode))
37
Fred Drake58422e52001-06-04 03:56:24 +000038 def check_suite(self, s):
39 self.roundtrip(parser.suite, s)
Fred Drake28f739a2000-08-25 22:42:40 +000040
Fred Drakecf580c72001-07-17 03:01:29 +000041 def test_yield_statement(self):
Tim Peters496563a2002-04-01 00:28:59 +000042 self.check_suite("def f(): yield 1")
Phillip J. Eby0d6615f2005-08-02 00:46:46 +000043 self.check_suite("def f(): yield")
44 self.check_suite("def f(): x += yield")
45 self.check_suite("def f(): x = yield 1")
46 self.check_suite("def f(): x = y = yield 1")
47 self.check_suite("def f(): x = yield")
48 self.check_suite("def f(): x = y = yield")
49 self.check_suite("def f(): 1 + (yield)*2")
50 self.check_suite("def f(): (yield 1)*2")
Tim Peters496563a2002-04-01 00:28:59 +000051 self.check_suite("def f(): return; yield 1")
52 self.check_suite("def f(): yield 1; return")
53 self.check_suite("def f():\n"
Fred Drakecf580c72001-07-17 03:01:29 +000054 " for x in range(30):\n"
55 " yield x\n")
Phillip J. Eby0d6615f2005-08-02 00:46:46 +000056 self.check_suite("def f():\n"
57 " if (yield):\n"
58 " yield x\n")
Fred Drakecf580c72001-07-17 03:01:29 +000059
Fred Drake58422e52001-06-04 03:56:24 +000060 def test_expressions(self):
61 self.check_expr("foo(1)")
62 self.check_expr("[1, 2, 3]")
63 self.check_expr("[x**3 for x in range(20)]")
64 self.check_expr("[x**3 for x in range(20) if x % 3]")
Neal Norwitzd3a91622006-04-12 05:27:46 +000065 self.check_expr("[x**3 for x in range(20) if x % 2 if x % 3]")
66 self.check_expr("list(x**3 for x in range(20))")
67 self.check_expr("list(x**3 for x in range(20) if x % 3)")
68 self.check_expr("list(x**3 for x in range(20) if x % 2 if x % 3)")
Fred Drake58422e52001-06-04 03:56:24 +000069 self.check_expr("foo(*args)")
70 self.check_expr("foo(*args, **kw)")
71 self.check_expr("foo(**kw)")
72 self.check_expr("foo(key=value)")
73 self.check_expr("foo(key=value, *args)")
74 self.check_expr("foo(key=value, *args, **kw)")
75 self.check_expr("foo(key=value, **kw)")
76 self.check_expr("foo(a, b, c, *args)")
77 self.check_expr("foo(a, b, c, *args, **kw)")
78 self.check_expr("foo(a, b, c, **kw)")
Benjamin Petersonbd6a05f2008-08-19 22:06:11 +000079 self.check_expr("foo(a, *args, keyword=23)")
Fred Drake58422e52001-06-04 03:56:24 +000080 self.check_expr("foo + bar")
Michael W. Hudson5e83b7a2003-01-29 14:20:23 +000081 self.check_expr("foo - bar")
82 self.check_expr("foo * bar")
83 self.check_expr("foo / bar")
84 self.check_expr("foo // bar")
Fred Drake58422e52001-06-04 03:56:24 +000085 self.check_expr("lambda: 0")
86 self.check_expr("lambda x: 0")
87 self.check_expr("lambda *y: 0")
88 self.check_expr("lambda *y, **z: 0")
89 self.check_expr("lambda **z: 0")
90 self.check_expr("lambda x, y: 0")
91 self.check_expr("lambda foo=bar: 0")
92 self.check_expr("lambda foo=bar, spaz=nifty+spit: 0")
93 self.check_expr("lambda foo=bar, **z: 0")
94 self.check_expr("lambda foo=bar, blaz=blat+2, **z: 0")
95 self.check_expr("lambda foo=bar, blaz=blat+2, *y, **z: 0")
96 self.check_expr("lambda x, *y, **z: 0")
Raymond Hettinger354433a2004-05-19 08:20:33 +000097 self.check_expr("(x for x in range(10))")
98 self.check_expr("foo(x for x in range(10))")
Fred Drake79ca79d2000-08-21 22:30:53 +000099
Fred Drake58422e52001-06-04 03:56:24 +0000100 def test_print(self):
101 self.check_suite("print")
102 self.check_suite("print 1")
103 self.check_suite("print 1,")
104 self.check_suite("print >>fp")
105 self.check_suite("print >>fp, 1")
106 self.check_suite("print >>fp, 1,")
Fred Drake79ca79d2000-08-21 22:30:53 +0000107
Fred Drake58422e52001-06-04 03:56:24 +0000108 def test_simple_expression(self):
109 # expr_stmt
110 self.check_suite("a")
Fred Drake79ca79d2000-08-21 22:30:53 +0000111
Fred Drake58422e52001-06-04 03:56:24 +0000112 def test_simple_assignments(self):
113 self.check_suite("a = b")
114 self.check_suite("a = b = c = d = e")
Fred Drake28f739a2000-08-25 22:42:40 +0000115
Fred Drake58422e52001-06-04 03:56:24 +0000116 def test_simple_augmented_assignments(self):
117 self.check_suite("a += b")
118 self.check_suite("a -= b")
119 self.check_suite("a *= b")
120 self.check_suite("a /= b")
Michael W. Hudson5e83b7a2003-01-29 14:20:23 +0000121 self.check_suite("a //= b")
Fred Drake58422e52001-06-04 03:56:24 +0000122 self.check_suite("a %= b")
123 self.check_suite("a &= b")
124 self.check_suite("a |= b")
125 self.check_suite("a ^= b")
126 self.check_suite("a <<= b")
127 self.check_suite("a >>= b")
128 self.check_suite("a **= b")
Fred Drakee3fb18c2001-01-07 06:02:19 +0000129
Fred Drake58422e52001-06-04 03:56:24 +0000130 def test_function_defs(self):
131 self.check_suite("def f(): pass")
132 self.check_suite("def f(*args): pass")
133 self.check_suite("def f(*args, **kw): pass")
134 self.check_suite("def f(**kw): pass")
135 self.check_suite("def f(foo=bar): pass")
136 self.check_suite("def f(foo=bar, *args): pass")
137 self.check_suite("def f(foo=bar, *args, **kw): pass")
138 self.check_suite("def f(foo=bar, **kw): pass")
Fred Drakee3fb18c2001-01-07 06:02:19 +0000139
Fred Drake58422e52001-06-04 03:56:24 +0000140 self.check_suite("def f(a, b): pass")
141 self.check_suite("def f(a, b, *args): pass")
142 self.check_suite("def f(a, b, *args, **kw): pass")
143 self.check_suite("def f(a, b, **kw): pass")
144 self.check_suite("def f(a, b, foo=bar): pass")
145 self.check_suite("def f(a, b, foo=bar, *args): pass")
146 self.check_suite("def f(a, b, foo=bar, *args, **kw): pass")
147 self.check_suite("def f(a, b, foo=bar, **kw): pass")
Fred Drakee3fb18c2001-01-07 06:02:19 +0000148
Anthony Baxterc2a5a632004-08-02 06:10:11 +0000149 self.check_suite("@staticmethod\n"
150 "def f(): pass")
151 self.check_suite("@staticmethod\n"
152 "@funcattrs(x, y)\n"
153 "def f(): pass")
154 self.check_suite("@funcattrs()\n"
155 "def f(): pass")
156
Brett Cannonf4189912005-04-09 02:30:16 +0000157 def test_class_defs(self):
158 self.check_suite("class foo():pass")
Mark Dickinson644bef72010-07-04 16:28:57 +0000159 self.check_suite("@class_decorator\n"
160 "class foo():pass")
161 self.check_suite("@class_decorator(arg)\n"
162 "class foo():pass")
163 self.check_suite("@decorator1\n"
164 "@decorator2\n"
165 "class foo():pass")
166
Tim Peterse8906822005-04-20 17:45:13 +0000167
Fred Drake58422e52001-06-04 03:56:24 +0000168 def test_import_from_statement(self):
169 self.check_suite("from sys.path import *")
170 self.check_suite("from sys.path import dirname")
Anthony Baxter1a4ddae2004-08-31 10:07:13 +0000171 self.check_suite("from sys.path import (dirname)")
172 self.check_suite("from sys.path import (dirname,)")
Fred Drake58422e52001-06-04 03:56:24 +0000173 self.check_suite("from sys.path import dirname as my_dirname")
Anthony Baxter1a4ddae2004-08-31 10:07:13 +0000174 self.check_suite("from sys.path import (dirname as my_dirname)")
175 self.check_suite("from sys.path import (dirname as my_dirname,)")
Fred Drake58422e52001-06-04 03:56:24 +0000176 self.check_suite("from sys.path import dirname, basename")
Anthony Baxter1a4ddae2004-08-31 10:07:13 +0000177 self.check_suite("from sys.path import (dirname, basename)")
178 self.check_suite("from sys.path import (dirname, basename,)")
Fred Drake58422e52001-06-04 03:56:24 +0000179 self.check_suite(
180 "from sys.path import dirname as my_dirname, basename")
181 self.check_suite(
Anthony Baxter1a4ddae2004-08-31 10:07:13 +0000182 "from sys.path import (dirname as my_dirname, basename)")
183 self.check_suite(
184 "from sys.path import (dirname as my_dirname, basename,)")
185 self.check_suite(
Fred Drake58422e52001-06-04 03:56:24 +0000186 "from sys.path import dirname, basename as my_basename")
Anthony Baxter1a4ddae2004-08-31 10:07:13 +0000187 self.check_suite(
188 "from sys.path import (dirname, basename as my_basename)")
189 self.check_suite(
190 "from sys.path import (dirname, basename as my_basename,)")
Benjamin Petersoneeed0c72008-11-03 15:18:30 +0000191 self.check_suite("from .bogus import x")
Fred Drakee3fb18c2001-01-07 06:02:19 +0000192
Fred Drake58422e52001-06-04 03:56:24 +0000193 def test_basic_import_statement(self):
194 self.check_suite("import sys")
195 self.check_suite("import sys as system")
196 self.check_suite("import sys, math")
197 self.check_suite("import sys as system, math")
198 self.check_suite("import sys, math as my_math")
Fred Drake79ca79d2000-08-21 22:30:53 +0000199
Mark Dickinson1a7f3022010-07-04 16:59:04 +0000200 def test_relative_imports(self):
201 self.check_suite("from . import name")
202 self.check_suite("from .. import name")
203 self.check_suite("from .pkg import name")
204 self.check_suite("from ..pkg import name")
205
Neal Norwitz9caf9c02003-02-10 01:54:06 +0000206 def test_pep263(self):
207 self.check_suite("# -*- coding: iso-8859-1 -*-\n"
208 "pass\n")
209
210 def test_assert(self):
211 self.check_suite("assert alo < ahi and blo < bhi\n")
212
Benjamin Peterson9e233a52008-11-24 04:19:49 +0000213 def test_with(self):
214 self.check_suite("with open('x'): pass\n")
215 self.check_suite("with open('x') as f: pass\n")
216
Georg Brandlf3a0b862008-12-07 14:47:12 +0000217 def test_try_stmt(self):
218 self.check_suite("try: pass\nexcept: pass\n")
219 self.check_suite("try: pass\nfinally: pass\n")
220 self.check_suite("try: pass\nexcept A: pass\nfinally: pass\n")
221 self.check_suite("try: pass\nexcept A: pass\nexcept: pass\n"
222 "finally: pass\n")
223 self.check_suite("try: pass\nexcept: pass\nelse: pass\n")
224 self.check_suite("try: pass\nexcept: pass\nelse: pass\n"
225 "finally: pass\n")
226
Mark Dickinson9f11f392010-06-30 16:33:23 +0000227 def test_except_clause(self):
228 self.check_suite("try: pass\nexcept: pass\n")
229 self.check_suite("try: pass\nexcept A: pass\n")
230 self.check_suite("try: pass\nexcept A, e: pass\n")
231 self.check_suite("try: pass\nexcept A as e: pass\n")
232
Jeremy Hylton60e96f62006-08-22 20:46:00 +0000233 def test_position(self):
234 # An absolutely minimal test of position information. Better
235 # tests would be a big project.
236 code = "def f(x):\n return x + 1\n"
237 st1 = parser.suite(code)
238 st2 = st1.totuple(line_info=1, col_info=1)
239
240 def walk(tree):
241 node_type = tree[0]
242 next = tree[1]
243 if isinstance(next, tuple):
244 for elt in tree[1:]:
245 for x in walk(elt):
246 yield x
247 else:
248 yield tree
Tim Peters147f9ae2006-08-25 22:05:39 +0000249
Jeremy Hylton60e96f62006-08-22 20:46:00 +0000250 terminals = list(walk(st2))
251 self.assertEqual([
252 (1, 'def', 1, 0),
253 (1, 'f', 1, 4),
254 (7, '(', 1, 5),
255 (1, 'x', 1, 6),
256 (8, ')', 1, 7),
257 (11, ':', 1, 8),
258 (4, '', 1, 9),
259 (5, '', 2, -1),
260 (1, 'return', 2, 4),
261 (1, 'x', 2, 11),
262 (14, '+', 2, 13),
263 (2, '1', 2, 15),
264 (4, '', 2, 16),
265 (6, '', 2, -1),
266 (4, '', 2, -1),
267 (0, '', 2, -1)],
268 terminals)
269
270
Fred Drake79ca79d2000-08-21 22:30:53 +0000271#
272# Second, we take *invalid* trees and make sure we get ParserError
273# rejections for them.
274#
275
Fred Drake58422e52001-06-04 03:56:24 +0000276class IllegalSyntaxTestCase(unittest.TestCase):
Guido van Rossum32c2ae72002-08-22 19:45:32 +0000277
Fred Drake58422e52001-06-04 03:56:24 +0000278 def check_bad_tree(self, tree, label):
279 try:
Fred Drake6e4f2c02001-07-17 19:33:25 +0000280 parser.sequence2st(tree)
Fred Drake58422e52001-06-04 03:56:24 +0000281 except parser.ParserError:
282 pass
283 else:
284 self.fail("did not detect invalid tree for %r" % label)
Fred Drake79ca79d2000-08-21 22:30:53 +0000285
Fred Drake58422e52001-06-04 03:56:24 +0000286 def test_junk(self):
287 # not even remotely valid:
288 self.check_bad_tree((1, 2, 3), "<junk>")
289
Fred Drakecf580c72001-07-17 03:01:29 +0000290 def test_illegal_yield_1(self):
Guido van Rossum32c2ae72002-08-22 19:45:32 +0000291 # Illegal yield statement: def f(): return 1; yield 1
Fred Drakecf580c72001-07-17 03:01:29 +0000292 tree = \
293 (257,
294 (264,
295 (285,
296 (259,
297 (1, 'def'),
298 (1, 'f'),
299 (260, (7, '('), (8, ')')),
300 (11, ':'),
301 (291,
302 (4, ''),
303 (5, ''),
304 (264,
305 (265,
306 (266,
307 (272,
308 (275,
309 (1, 'return'),
310 (313,
311 (292,
312 (293,
313 (294,
314 (295,
315 (297,
316 (298,
317 (299,
318 (300,
319 (301,
320 (302, (303, (304, (305, (2, '1')))))))))))))))))),
321 (264,
322 (265,
323 (266,
324 (272,
325 (276,
326 (1, 'yield'),
327 (313,
328 (292,
329 (293,
330 (294,
331 (295,
332 (297,
333 (298,
334 (299,
335 (300,
336 (301,
337 (302,
338 (303, (304, (305, (2, '1')))))))))))))))))),
339 (4, ''))),
340 (6, ''))))),
341 (4, ''),
342 (0, ''))))
343 self.check_bad_tree(tree, "def f():\n return 1\n yield 1")
344
345 def test_illegal_yield_2(self):
Guido van Rossum32c2ae72002-08-22 19:45:32 +0000346 # Illegal return in generator: def f(): return 1; yield 1
Fred Drakecf580c72001-07-17 03:01:29 +0000347 tree = \
348 (257,
349 (264,
350 (265,
351 (266,
352 (278,
353 (1, 'from'),
354 (281, (1, '__future__')),
355 (1, 'import'),
356 (279, (1, 'generators')))),
357 (4, ''))),
358 (264,
359 (285,
360 (259,
361 (1, 'def'),
362 (1, 'f'),
363 (260, (7, '('), (8, ')')),
364 (11, ':'),
365 (291,
366 (4, ''),
367 (5, ''),
368 (264,
369 (265,
370 (266,
371 (272,
372 (275,
373 (1, 'return'),
374 (313,
375 (292,
376 (293,
377 (294,
378 (295,
379 (297,
380 (298,
381 (299,
382 (300,
383 (301,
384 (302, (303, (304, (305, (2, '1')))))))))))))))))),
385 (264,
386 (265,
387 (266,
388 (272,
389 (276,
390 (1, 'yield'),
391 (313,
392 (292,
393 (293,
394 (294,
395 (295,
396 (297,
397 (298,
398 (299,
399 (300,
400 (301,
401 (302,
402 (303, (304, (305, (2, '1')))))))))))))))))),
403 (4, ''))),
404 (6, ''))))),
405 (4, ''),
406 (0, ''))))
407 self.check_bad_tree(tree, "def f():\n return 1\n yield 1")
408
Fred Drake58422e52001-06-04 03:56:24 +0000409 def test_print_chevron_comma(self):
Guido van Rossum32c2ae72002-08-22 19:45:32 +0000410 # Illegal input: print >>fp,
Fred Drake58422e52001-06-04 03:56:24 +0000411 tree = \
412 (257,
413 (264,
414 (265,
415 (266,
416 (268,
417 (1, 'print'),
418 (35, '>>'),
419 (290,
420 (291,
421 (292,
422 (293,
423 (295,
424 (296,
425 (297,
426 (298, (299, (300, (301, (302, (303, (1, 'fp')))))))))))))),
427 (12, ','))),
428 (4, ''))),
429 (0, ''))
430 self.check_bad_tree(tree, "print >>fp,")
431
432 def test_a_comma_comma_c(self):
Guido van Rossum32c2ae72002-08-22 19:45:32 +0000433 # Illegal input: a,,c
Fred Drake58422e52001-06-04 03:56:24 +0000434 tree = \
435 (258,
436 (311,
437 (290,
438 (291,
439 (292,
440 (293,
441 (295,
442 (296,
443 (297,
444 (298, (299, (300, (301, (302, (303, (1, 'a')))))))))))))),
445 (12, ','),
446 (12, ','),
447 (290,
448 (291,
449 (292,
450 (293,
451 (295,
452 (296,
453 (297,
454 (298, (299, (300, (301, (302, (303, (1, 'c'))))))))))))))),
455 (4, ''),
456 (0, ''))
457 self.check_bad_tree(tree, "a,,c")
458
459 def test_illegal_operator(self):
Guido van Rossum32c2ae72002-08-22 19:45:32 +0000460 # Illegal input: a $= b
Fred Drake58422e52001-06-04 03:56:24 +0000461 tree = \
462 (257,
463 (264,
464 (265,
465 (266,
466 (267,
467 (312,
468 (291,
469 (292,
470 (293,
471 (294,
472 (296,
473 (297,
474 (298,
475 (299,
476 (300, (301, (302, (303, (304, (1, 'a'))))))))))))))),
477 (268, (37, '$=')),
478 (312,
479 (291,
480 (292,
481 (293,
482 (294,
483 (296,
484 (297,
485 (298,
486 (299,
487 (300, (301, (302, (303, (304, (1, 'b'))))))))))))))))),
488 (4, ''))),
489 (0, ''))
490 self.check_bad_tree(tree, "a $= b")
Fred Drake79ca79d2000-08-21 22:30:53 +0000491
Neal Norwitz9caf9c02003-02-10 01:54:06 +0000492 def test_malformed_global(self):
493 #doesn't have global keyword in ast
494 tree = (257,
495 (264,
496 (265,
497 (266,
498 (282, (1, 'foo'))), (4, ''))),
499 (4, ''),
Tim Petersf2715e02003-02-19 02:35:07 +0000500 (0, ''))
Neal Norwitz9caf9c02003-02-10 01:54:06 +0000501 self.check_bad_tree(tree, "malformed global ast")
Fred Drake79ca79d2000-08-21 22:30:53 +0000502
Mark Dickinson1a7f3022010-07-04 16:59:04 +0000503 def test_missing_import_source(self):
504 # from import a
505 tree = \
506 (257,
507 (267,
508 (268,
509 (269,
510 (281,
511 (283, (1, 'from'), (1, 'import'),
512 (286, (284, (1, 'fred')))))),
513 (4, ''))),
514 (4, ''), (0, ''))
515 self.check_bad_tree(tree, "from import a")
516
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000517
518class CompileTestCase(unittest.TestCase):
519
520 # These tests are very minimal. :-(
521
522 def test_compile_expr(self):
523 st = parser.expr('2 + 3')
524 code = parser.compilest(st)
525 self.assertEquals(eval(code), 5)
526
527 def test_compile_suite(self):
528 st = parser.suite('x = 2; y = x + 3')
529 code = parser.compilest(st)
530 globs = {}
531 exec code in globs
532 self.assertEquals(globs['y'], 5)
533
534 def test_compile_error(self):
535 st = parser.suite('1 = 3 + 4')
536 self.assertRaises(SyntaxError, parser.compilest, st)
537
Guido van Rossumb6ac23c2007-07-18 17:19:14 +0000538 def test_compile_badunicode(self):
539 st = parser.suite('a = u"\U12345678"')
540 self.assertRaises(SyntaxError, parser.compilest, st)
541 st = parser.suite('a = u"\u1"')
542 self.assertRaises(SyntaxError, parser.compilest, st)
543
Facundo Batistafc2d0102008-02-23 12:01:13 +0000544class ParserStackLimitTestCase(unittest.TestCase):
545 """try to push the parser to/over it's limits.
546 see http://bugs.python.org/issue1881 for a discussion
547 """
548 def _nested_expression(self, level):
549 return "["*level+"]"*level
550
551 def test_deeply_nested_list(self):
552 e = self._nested_expression(99)
553 st = parser.expr(e)
554 st.compile()
555
556 def test_trigger_memory_error(self):
557 e = self._nested_expression(100)
Martin v. Löwis66e26632008-03-18 13:16:05 +0000558 print >>sys.stderr, "Expecting 's_push: parser stack overflow' in next line"
Facundo Batistafc2d0102008-02-23 12:01:13 +0000559 self.assertRaises(MemoryError, parser.expr, e)
560
Fred Drake2e2be372001-09-20 21:33:42 +0000561def test_main():
Walter Dörwald21d3a322003-05-01 17:45:56 +0000562 test_support.run_unittest(
563 RoundtripLegalSyntaxTestCase,
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000564 IllegalSyntaxTestCase,
565 CompileTestCase,
Facundo Batistafc2d0102008-02-23 12:01:13 +0000566 ParserStackLimitTestCase,
Walter Dörwald21d3a322003-05-01 17:45:56 +0000567 )
Fred Drake2e2be372001-09-20 21:33:42 +0000568
569
570if __name__ == "__main__":
571 test_main()