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)