[Python-checkins] CVS: python/dist/src/Lib/test test_parser.py,1.3,1.4

Fred L. Drake python-dev@python.org
Sat, 06 Jan 2001 22:02:21 -0800


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv13664/Lib/test

Modified Files:
	test_parser.py 
Log Message:

Add more regression tests, including for the import statement variations.
These will detect regression on SF bug #127271 and other import statement
bugs.


Index: test_parser.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_parser.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** test_parser.py	2000/12/11 22:12:09	1.3
--- test_parser.py	2001/01/07 06:02:19	1.4
***************
*** 4,9 ****
  import sys
  
! from parser import expr, suite, sequence2ast
! from test_support import verbose
  
  #
--- 4,8 ----
  import sys
  
! from test_support import TestFailed
  
  #
***************
*** 19,36 ****
          st2 = parser.sequence2ast(t)
      except parser.ParserError:
!         print "Failing syntax tree:"
!         pprint.pprint(t)
!         raise
  
  def roundtrip_fromfile(filename):
!     roundtrip(suite, open(filename).read())
  
  def test_expr(s):
      print "expr:", s
!     roundtrip(expr, s)
  
  def test_suite(s):
      print "suite:", s
!     roundtrip(suite, s)
  
  
--- 18,33 ----
          st2 = parser.sequence2ast(t)
      except parser.ParserError:
!         raise TestFailed, s
  
  def roundtrip_fromfile(filename):
!     roundtrip(parser.suite, open(filename).read())
  
  def test_expr(s):
      print "expr:", s
!     roundtrip(parser.expr, s)
  
  def test_suite(s):
      print "suite:", s
!     roundtrip(parser.suite, s)
  
  
***************
*** 89,94 ****
--- 86,120 ----
  test_suite("a >>= b")
  test_suite("a **= b")
+ 
  test_suite("def f(): pass")
+ test_suite("def f(*args): pass")
+ test_suite("def f(*args, **kw): pass")
+ test_suite("def f(**kw): pass")
  test_suite("def f(foo=bar): pass")
+ test_suite("def f(foo=bar, *args): pass")
+ test_suite("def f(foo=bar, *args, **kw): pass")
+ test_suite("def f(foo=bar, **kw): pass")
+ 
+ test_suite("def f(a, b): pass")
+ test_suite("def f(a, b, *args): pass")
+ test_suite("def f(a, b, *args, **kw): pass")
+ test_suite("def f(a, b, **kw): pass")
+ test_suite("def f(a, b, foo=bar): pass")
+ test_suite("def f(a, b, foo=bar, *args): pass")
+ test_suite("def f(a, b, foo=bar, *args, **kw): pass")
+ test_suite("def f(a, b, foo=bar, **kw): pass")
+ 
+ test_suite("from sys.path import *")
+ test_suite("from sys.path import dirname")
+ test_suite("from sys.path import dirname as my_dirname")
+ test_suite("from sys.path import dirname, basename")
+ test_suite("from sys.path import dirname as my_dirname, basename")
+ test_suite("from sys.path import dirname, basename as my_basename")
+ 
+ test_suite("import sys")
+ test_suite("import sys as system")
+ test_suite("import sys, math")
+ test_suite("import sys as system, math")
+ test_suite("import sys, math as my_math")
  
  #d = os.path.dirname(os.__file__)
***************
*** 108,115 ****
      print label
      try:
!         sequence2ast(tree)
      except parser.ParserError:
          print "caught expected exception for invalid tree"
-         pass
      else:
          print "test failed: did not properly detect invalid tree:"
--- 134,140 ----
      print label
      try:
!         parser.sequence2ast(tree)
      except parser.ParserError:
          print "caught expected exception for invalid tree"
      else:
          print "test failed: did not properly detect invalid tree:"