Skip to content

Commit 26b55f8

Browse files
authored
pytest: use PYTHONPATH, not ., as first entry in sys.path (#166)
Python 3.11 has the `-P` flag. For other Pythons, we invoke `pytest` directly, which seems to handle PYTHONPATH correctly. Closes #165
1 parent 298494d commit 26b55f8

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

spin/cmds/meson.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,13 @@ def test(ctx, pytest_args, n_jobs, tests, verbose, coverage=False, gcov=False):
363363
]
364364

365365
print(f'$ export PYTHONPATH="{site_path}"')
366+
367+
if sys.version_info[:2] >= (3, 11):
368+
cmd = [sys.executable, "-P", "-m", "pytest"]
369+
else:
370+
cmd = ["pytest"]
366371
_run(
367-
[sys.executable, "-m", "pytest", f"--rootdir={site_path}"] + list(pytest_args),
368-
cwd=site_path,
372+
cmd + list(pytest_args),
369373
replace=True,
370374
)
371375

0 commit comments

Comments
 (0)