Commit d4660f1a authored by Michael Droettboom's avatar Michael Droettboom Committed by GitHub

Merge pull request #143 from rth/make_test_list.py

MAINT Fix and refactor tests/make_test_list.py
parents 4da3106a fb13af04
...@@ -5,24 +5,36 @@ Generate a list of test modules in the CPython distribution. ...@@ -5,24 +5,36 @@ Generate a list of test modules in the CPython distribution.
import os import os
from pathlib import Path from pathlib import Path
tests = []
TEST_DIR = (Path(__file__).parent
TEST_DIR = Path("../cpython/build/3.6.4/host/lib/python3.6/test") / "cpython/build/3.6.4/host/lib/python3.6/test")
for root, dirs, files in os.walk(
"../cpython/build/3.6.4/host/lib/python3.6/test"): def collect_tests(base_dir):
root = Path(root).relative_to(TEST_DIR) """Collect CPython unit tests"""
if root == '.': # Note: this functionality is somewhat equivalent to pytest test
root = '' # collection.
else: tests = []
root = '.'.join(root.split('/')) + '.'
for root, dirs, files in os.walk(base_dir):
for filename in files: root = Path(root).relative_to(base_dir)
filename = Path(filename)
if str(filename).startswith("test_") and filename.suffix == ".py": if str(root) == '.':
tests.append(str(root / filename.stem)) root = ''
else:
tests.sort() root = '.'.join(str(root).split('/')) + '.'
with open("python_tests.txt", "w") as fp:
for test in tests: for filename in files:
fp.write(test + '\n') filename = Path(filename)
if str(filename).startswith("test_") and filename.suffix == ".py":
tests.append(root + filename.stem)
tests.sort()
return tests
if __name__ == '__main__':
tests = collect_tests(TEST_DIR)
with open("python_tests.txt", "w") as fp:
for test in tests:
fp.write(test + '\n')
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment