42 lines
1013 B
Python
42 lines
1013 B
Python
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).parent.parent
|
|
TESTS_DIR = Path(__file__).parent
|
|
RESULTS_JSON = TESTS_DIR / "results.json"
|
|
REPORT_HTML = TESTS_DIR / "charts" / "report.html"
|
|
CHARTS_DIR = TESTS_DIR / "charts"
|
|
|
|
|
|
def run_pytest() -> int:
|
|
CHARTS_DIR.mkdir(parents=True, exist_ok=True)
|
|
|
|
args = [
|
|
sys.executable, "-m", "pytest",
|
|
str(TESTS_DIR / "tests"),
|
|
|
|
f"--html={REPORT_HTML}",
|
|
"--self-contained-html",
|
|
|
|
"--cov=api",
|
|
"--cov=core",
|
|
"--cov-report=term-missing",
|
|
f"--cov-report=html:{CHARTS_DIR / 'coverage'}",
|
|
|
|
"--tb=no",
|
|
"-q",
|
|
]
|
|
|
|
return subprocess.run(args, cwd=str(ROOT), check=False).returncode
|
|
|
|
if __name__ == "__main__":
|
|
print("Start testing")
|
|
code = run_pytest()
|
|
charts_path = None
|
|
print(f"\npytest-html: {REPORT_HTML}")
|
|
print(f"pytest-cov: {CHARTS_DIR / 'coverage' / 'index.html'}")
|
|
|
|
print("\nStop testing")
|
|
|
|
sys.exit(code) |