Skip to content

Commit faa685f

Browse files
committed
Fix tests
1 parent ec0eed3 commit faa685f

3 files changed

Lines changed: 20 additions & 13 deletions

File tree

bench_runner/__main__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import importlib
2+
import os
23
import sys
34

45

@@ -25,6 +26,15 @@
2526
}
2627

2728
if __name__ == "__main__":
29+
# This lets pytest-cov collect coverage data in a subprocess
30+
if "COV_CORE_SOURCE" in os.environ:
31+
try:
32+
from pytest_cov.embed import init
33+
34+
init()
35+
except Exception:
36+
sys.stderr.write("pytest-cov: Failed to setup subprocess coverage.")
37+
2838
command = len(sys.argv) >= 2 and sys.argv[1] or ""
2939

3040
if command not in COMMANDS:
@@ -37,5 +47,5 @@
3747
sys.exit(1)
3848

3949
sys.argv = [sys.argv[0], *sys.argv[2:]]
40-
mod = importlib.import_module(f"bench_runner.scripts.{command}")
50+
mod = importlib.import_module(f".{command}", "bench_runner.scripts")
4151
mod.main()

bench_runner/scripts/workflow.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -398,13 +398,4 @@ def main():
398398

399399

400400
if __name__ == "__main__":
401-
# This lets pytest-cov collect coverage data in a subprocess
402-
if "COV_CORE_SOURCE" in os.environ:
403-
try:
404-
from pytest_cov.embed import init
405-
406-
init()
407-
except Exception:
408-
sys.stderr.write("pytest-cov: Failed to setup subprocess coverage.")
409-
410401
main()

tests/test_run_benchmarks.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ def test_run_benchmarks(benchmarks_checkout, monkeypatch):
8383
subprocess.check_call(
8484
[
8585
venv_python,
86-
run_benchmarks.__file__,
86+
"-m",
87+
"bench_runner",
88+
"run_benchmarks",
8789
"benchmark",
8890
sys.executable,
8991
"python",
@@ -132,7 +134,9 @@ def test_run_benchmarks(benchmarks_checkout, monkeypatch):
132134
returncode = subprocess.call(
133135
[
134136
venv_python,
135-
run_benchmarks.__file__,
137+
"-m",
138+
"bench_runner",
139+
"run_benchmarks",
136140
"benchmark",
137141
sys.executable,
138142
"python",
@@ -164,7 +168,9 @@ def test_run_benchmarks_flags(benchmarks_checkout):
164168
subprocess.check_call(
165169
[
166170
venv_python,
167-
run_benchmarks.__file__,
171+
"-m",
172+
"bench_runner",
173+
"run_benchmarks",
168174
"benchmark",
169175
sys.executable,
170176
"python",

0 commit comments

Comments
 (0)