Skip to content

Commit 148aa41

Browse files
fix script path in unit test
1 parent 15f1bf4 commit 148aa41

2 files changed

Lines changed: 38 additions & 10 deletions

File tree

pywt/conftest.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from pytest import fixture
55
from typing import Iterator
66

7+
78
def pytest_configure(config):
89
config.addinivalue_line("markers",
910
"slow: Tests that are slow.")
@@ -68,3 +69,28 @@ def baseline_report(tmp_path: Path) -> Iterator[Path]:
6869
# Cleanup report file
6970
baseline_report_path.unlink()
7071

72+
73+
@pytest.fixture(scope="session")
74+
def pyrefly_script_path(request) -> Path:
75+
"""
76+
Path to check_pyrefly_coverage.py script.
77+
"""
78+
pytest_root = Path(request.config.rootdir).resolve()
79+
80+
print(pytest_root)
81+
82+
repo_root = pytest_root
83+
while repo_root != repo_root.parent:
84+
if (repo_root / ".github").exists():
85+
break
86+
repo_root = repo_root.parent
87+
88+
script_path = repo_root / ".github" / "scripts" / "check_pyrefly_coverage.py"
89+
90+
if not script_path.exists():
91+
raise FileNotFoundError(
92+
f"Could not locate check_pyrefly_coverage.py at: {script_path}\n"
93+
f"Current working directory: {Path.cwd()}"
94+
)
95+
96+
return script_path

pywt/tests/test_check_pyrefly_report.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
import sys
66

77

8-
def test_no_changes_implies_no_regression(baseline_report: Path, tmp_path: Path):
8+
def test_no_changes_implies_no_regression(
9+
baseline_report: Path, tmp_path: Path, pyrefly_script_path: Path
10+
):
911

1012
current_report = tmp_path / "pyrefly-test-current-report.json"
1113

@@ -14,7 +16,7 @@ def test_no_changes_implies_no_regression(baseline_report: Path, tmp_path: Path)
1416
process: subprocess.CompletedProcess = subprocess.run(
1517
[
1618
sys.executable,
17-
".github/scripts/check_pyrefly_coverage.py",
19+
pyrefly_script_path,
1820
"--baseline_report_path",
1921
baseline_report,
2022
"--current_report_path",
@@ -28,7 +30,7 @@ def test_no_changes_implies_no_regression(baseline_report: Path, tmp_path: Path)
2830

2931

3032
def test_increasing_type_coverage_implies_no_regression(
31-
baseline_report: Path, tmp_path: Path
33+
baseline_report: Path, tmp_path: Path, pyrefly_script_path: Path
3234
):
3335

3436
current_report = tmp_path / "pyrefly-test-current-report.json"
@@ -48,7 +50,7 @@ def test_increasing_type_coverage_implies_no_regression(
4850
process: subprocess.CompletedProcess = subprocess.run(
4951
[
5052
sys.executable,
51-
".github/scripts/check_pyrefly_coverage.py",
53+
pyrefly_script_path,
5254
"--baseline_report_path",
5355
baseline_report,
5456
"--current_report_path",
@@ -62,7 +64,7 @@ def test_increasing_type_coverage_implies_no_regression(
6264

6365

6466
def test_decreasing_type_coverage_implies_regression(
65-
baseline_report: Path, tmp_path: Path
67+
baseline_report: Path, tmp_path: Path, pyrefly_script_path: Path
6668
):
6769

6870
current_report = tmp_path / "pyrefly-test-current-report.json"
@@ -82,7 +84,7 @@ def test_decreasing_type_coverage_implies_regression(
8284
process: subprocess.CompletedProcess = subprocess.run(
8385
[
8486
sys.executable,
85-
".github/scripts/check_pyrefly_coverage.py",
87+
pyrefly_script_path,
8688
"--baseline_report_path",
8789
baseline_report,
8890
"--current_report_path",
@@ -97,7 +99,7 @@ def test_decreasing_type_coverage_implies_regression(
9799

98100

99101
def test_adding_fully_annotated_file_implies_no_regression(
100-
baseline_report: Path, tmp_path: Path
102+
baseline_report: Path, tmp_path: Path, pyrefly_script_path: Path
101103
):
102104

103105
current_report = tmp_path / "pyrefly-test-current-report.json"
@@ -138,7 +140,7 @@ def test_adding_fully_annotated_file_implies_no_regression(
138140
process: subprocess.CompletedProcess = subprocess.run(
139141
[
140142
sys.executable,
141-
".github/scripts/check_pyrefly_coverage.py",
143+
pyrefly_script_path,
142144
"--baseline_report_path",
143145
baseline_report,
144146
"--current_report_path",
@@ -152,7 +154,7 @@ def test_adding_fully_annotated_file_implies_no_regression(
152154

153155

154156
def test_adding_partially_annotated_file_implies_regression(
155-
baseline_report: Path, tmp_path: Path
157+
baseline_report: Path, tmp_path: Path, pyrefly_script_path: Path
156158
):
157159

158160
current_report = tmp_path / "pyrefly-test-current-report.json"
@@ -193,7 +195,7 @@ def test_adding_partially_annotated_file_implies_regression(
193195
process: subprocess.CompletedProcess = subprocess.run(
194196
[
195197
sys.executable,
196-
".github/scripts/check_pyrefly_coverage.py",
198+
pyrefly_script_path,
197199
"--baseline_report_path",
198200
baseline_report,
199201
"--current_report_path",

0 commit comments

Comments
 (0)