Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
yt-project
GitHub Repository: yt-project/yt
Path: blob/main/tests/pytest_runner.py
928 views
1
"""This is a helper script for running answer tests on CI services.
2
3
It's currently used on:
4
* Jenkins
5
* GHA
6
for executing answer tests and optionally generating new answers.
7
"""
8
9
import glob
10
import os
11
12
import pytest
13
14
if __name__ == "__main__":
15
os.environ["OMP_NUM_THREADS"] = "1"
16
pytest_args = [
17
"-s",
18
"-v",
19
"-rsfE", # it means -r "sfE" (show skipped, failed, errors), no -r -s -f -E
20
"--with-answer-testing",
21
"-m answer_test",
22
f"-n {int(os.environ.get('NUM_WORKERS', 1))}",
23
"--dist=loadscope",
24
]
25
pytest.main(pytest_args + ["--local-dir=answer-store", "--junitxml=answers.xml"])
26
27
if files := glob.glob("generate_test*.txt"):
28
tests = set()
29
for fname in files:
30
with open(fname) as fp:
31
tests |= set(fp.read().splitlines())
32
output_dir = "artifacts"
33
if not os.path.isdir(output_dir):
34
os.mkdir(output_dir)
35
pytest.main(
36
pytest_args + [f"--local-dir={output_dir}", "--answer-store"] + list(tests)
37
)
38
39