From 78d0d4656b86d811050593732357c1b0ed19822d Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Sat, 29 Aug 2009 11:31:42 -0500 Subject: [PATCH] add a test which checks the syntax of the pylib on various python versions --HG-- branch : trunk --- py/_testing/check_compile.py | 10 ++++++++++ py/_testing/test_sources.py | 19 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 py/_testing/check_compile.py create mode 100644 py/_testing/test_sources.py diff --git a/py/_testing/check_compile.py b/py/_testing/check_compile.py new file mode 100644 index 000000000..c982babbf --- /dev/null +++ b/py/_testing/check_compile.py @@ -0,0 +1,10 @@ +import sys + +fn = sys.argv[1] +print("Testing %s" % (fn,)) +fp = open(fn, "rb") +try: + source = fp.read() +finally: + fp.close() +compile(source, fn, "exec") diff --git a/py/_testing/test_sources.py b/py/_testing/test_sources.py new file mode 100644 index 000000000..1ea4ae8a8 --- /dev/null +++ b/py/_testing/test_sources.py @@ -0,0 +1,19 @@ +import os +import py + + +this_dir = py.path.local(__file__).dirpath() +_compile_checker = this_dir.join("check_compile.py") +_py_root = this_dir.join("..") +del this_dir + +@py.test.mark.multi(pyversion=("2.4", "2.5", "2.6", "3.1")) +def test_syntax(pyversion): + executable = py.path.local.sysfind("python" + pyversion) + if executable is None: + py.test.skip("no python%s found" % (pyversion,)) + for path, dirs, filenames in os.walk(str(_py_root)): + for fn in filenames: + if fn.endswith(".py"): + full = os.path.join(path, fn) + executable.sysexec(_compile_checker, full)