]>
git.proxmox.com Git - mirror_edk2.git/blob - AppPkg/Applications/Python/Python-2.7.2/Lib/lib2to3/tests/pytree_idempotency.py
05991b0695f068830dc0004e7de281ef069f522a
2 # Copyright 2006 Google, Inc. All Rights Reserved.
3 # Licensed to PSF under a Contributor Agreement.
5 """Main program for testing the infrastructure."""
7 __author__
= "Guido van Rossum <guido@python.org>"
9 # Support imports (need to be imported first)
20 from pgen2
import driver
25 gr
= driver
.load_grammar("Grammar.txt")
26 dr
= driver
.Driver(gr
, convert
=pytree
.convert
)
29 tree
= dr
.parse_file(fn
, debug
=True)
30 if not diff(fn
, tree
):
33 return # Pass a dummy argument to run the complete test suite below
37 # Process every imported module
38 for name
in sys
.modules
:
39 mod
= sys
.modules
[name
]
40 if mod
is None or not hasattr(mod
, "__file__"):
43 if fn
.endswith(".pyc"):
45 if not fn
.endswith(".py"):
47 print >>sys
.stderr
, "Parsing", fn
48 tree
= dr
.parse_file(fn
, debug
=True)
52 # Process every single module on sys.path (but not in packages)
55 names
= os
.listdir(dir)
58 print >>sys
.stderr
, "Scanning", dir, "..."
60 if not name
.endswith(".py"):
62 print >>sys
.stderr
, "Parsing", name
63 fn
= os
.path
.join(dir, name
)
65 tree
= dr
.parse_file(fn
, debug
=True)
66 except pgen2
.parse
.ParseError
, err
:
67 print "ParseError:", err
72 # Show summary of problem files
74 print "No problems. Congratulations!"
76 print "Problems in following files:"
87 return os
.system("diff -u %s @" % fn
)
91 if __name__
== "__main__":