[Python-checkins] r54251 - in sandbox/trunk/2to3: README play.py tests/pytree_idempotency.py

collin.winter python-checkins at python.org
Sat Mar 10 01:10:37 CET 2007


Author: collin.winter
Date: Sat Mar 10 01:10:36 2007
New Revision: 54251

Added:
   sandbox/trunk/2to3/tests/pytree_idempotency.py
      - copied unchanged from r54250, sandbox/trunk/2to3/play.py
Removed:
   sandbox/trunk/2to3/play.py
Modified:
   sandbox/trunk/2to3/README
Log:
Move play.py to tests/pytree_idempotency.py.


Modified: sandbox/trunk/2to3/README
==============================================================================
--- sandbox/trunk/2to3/README	(original)
+++ sandbox/trunk/2to3/README	Sat Mar 10 01:10:36 2007
@@ -6,7 +6,6 @@
 
 README         - this file
 test.py        - runs all unittests for 2to3
-play.py        - program to exercise the idempotency of pytree nodes
 patcomp.py     - pattern compiler
 pytree.py      - parse tree nodes (not specific to Python, despite the name!)
 pygram.py      - code specific to the Python grammar

Deleted: /sandbox/trunk/2to3/play.py
==============================================================================
--- /sandbox/trunk/2to3/play.py	Sat Mar 10 01:10:36 2007
+++ (empty file)
@@ -1,89 +0,0 @@
-#!/usr/bin/env python2.5
-# Copyright 2006 Google, Inc. All Rights Reserved.
-# Licensed to PSF under a Contributor Agreement.
-
-"""Main program for testing the infrastructure."""
-
-__author__ = "Guido van Rossum <guido at python.org>"
-
-# Python imports
-import os
-import sys
-import logging
-
-import pgen2
-from pgen2 import driver
-
-import pytree
-
-logging.basicConfig(level=logging.WARN)
-
-def main():
-    gr = driver.load_grammar("Grammar.txt")
-    dr = driver.Driver(gr, convert=pytree.convert)
-
-    fn = "example.py"
-    tree = dr.parse_file(fn, debug=True)
-    if not diff(fn, tree):
-      print "No diffs."
-    if not sys.argv[1:]:
-      return # Pass a dummy argument to run the complete test suite below
-
-    problems = []
-
-    # Process every imported module
-    for name in sys.modules:
-        mod = sys.modules[name]
-        if mod is None or not hasattr(mod, "__file__"):
-            continue
-        fn = mod.__file__
-        if fn.endswith(".pyc"):
-            fn = fn[:-1]
-        if not fn.endswith(".py"):
-            continue
-        print >>sys.stderr, "Parsing", fn
-        tree = dr.parse_file(fn, debug=True)
-        if diff(fn, tree):
-            problems.append(fn)
-
-    # Process every single module on sys.path (but not in packages)
-    for dir in sys.path:
-        try:
-            names = os.listdir(dir)
-        except os.error:
-            continue
-        print >>sys.stderr, "Scanning", dir, "..."
-        for name in names:
-            if not name.endswith(".py"):
-                continue
-            print >>sys.stderr, "Parsing", name
-            fn = os.path.join(dir, name)
-            try:
-                tree = dr.parse_file(fn, debug=True)
-            except pgen2.parse.ParseError, err:
-                print "ParseError:", err
-            else:
-                if diff(fn, tree):
-                    problems.append(fn)
-
-    # Show summary of problem files
-    if not problems:
-        print "No problems.  Congratulations!"
-    else:
-        print "Problems in following files:"
-        for fn in problems:
-            print "***", fn
-
-def diff(fn, tree):
-    f = open("@", "w")
-    try:
-        f.write(str(tree))
-    finally:
-        f.close()
-    try:
-        return os.system("diff -u %s @" % fn)
-    finally:
-        os.remove("@")
-
-if __name__ == "__main__":
-    main()


More information about the Python-checkins mailing list