Skip to content

Commit 8409b88

Browse files
authored
testupdatedata: fix cwd (#15383)
This should allow the inner pytest to pass even when the outer pytest is invoked outside of the mypy root, e.g. ```shell cd .. pytest mypy/mypy/test/testupdatedata.py ``` Addresses #15283 (comment).
1 parent 66bd2c4 commit 8409b88

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

mypy/test/testupdatedata.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ def _run_pytest_update_data(self, data_suite: str, *, max_attempts: int) -> str:
1414
Runs a suite of data test cases through 'pytest --update-data' until either tests pass
1515
or until a maximum number of attempts (needed for incremental tests).
1616
"""
17-
p = Path(test_data_prefix) / "check-update-data.test"
17+
p_test_data = Path(test_data_prefix)
18+
p_root = p_test_data.parent.parent
19+
p = p_test_data / "check-update-data.test"
1820
assert not p.exists()
1921
try:
2022
p.write_text(textwrap.dedent(data_suite).lstrip())
@@ -26,7 +28,7 @@ def _run_pytest_update_data(self, data_suite: str, *, max_attempts: int) -> str:
2628
else:
2729
cmd = " ".join(args)
2830
for i in range(max_attempts - 1, -1, -1):
29-
res = subprocess.run(args)
31+
res = subprocess.run(args, cwd=p_root)
3032
if res.returncode == 0:
3133
break
3234
print(f"`{cmd}` returned {res.returncode}: {i} attempts remaining")

0 commit comments

Comments
 (0)