2018-04-09 14:39:52 +00:00
|
|
|
"""
|
|
|
|
Generate a list of test modules in the CPython distribution.
|
|
|
|
"""
|
|
|
|
|
|
|
|
import os
|
2018-08-03 16:48:22 +00:00
|
|
|
from pathlib import Path
|
2018-04-09 14:39:52 +00:00
|
|
|
|
2018-09-06 12:28:23 +00:00
|
|
|
|
|
|
|
TEST_DIR = (Path(__file__).parent
|
2018-09-20 17:37:32 +00:00
|
|
|
/ "cpython/build/3.7.0/host/lib/python3.7/test")
|
2018-09-06 12:28:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
def collect_tests(base_dir):
|
|
|
|
"""Collect CPython unit tests"""
|
|
|
|
# Note: this functionality is somewhat equivalent to pytest test
|
|
|
|
# collection.
|
|
|
|
tests = []
|
|
|
|
|
|
|
|
for root, dirs, files in os.walk(base_dir):
|
|
|
|
root = Path(root).relative_to(base_dir)
|
|
|
|
|
|
|
|
if str(root) == '.':
|
|
|
|
root = ''
|
|
|
|
else:
|
|
|
|
root = '.'.join(str(root).split('/')) + '.'
|
|
|
|
|
|
|
|
for filename in files:
|
|
|
|
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')
|