Skip to content

Commit 7830aec

Browse files
committed
Use --pyargs to select package to test
Also do not switch out of source path when running tests. - Allow testing src/ layout tests - Better support editable install tests See scientific-python#185
1 parent 0157ef5 commit 7830aec

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

spin/cmds/meson.py

+8-10
Original file line numberDiff line numberDiff line change
@@ -439,13 +439,14 @@ def test(
439439
ctx.invoke(build_cmd)
440440

441441
package = cfg.get("tool.spin.package", None)
442+
if package is None:
443+
print(
444+
"Please specify `package = packagename` under `tool.spin` section of `pyproject.toml`"
445+
)
446+
raise SystemExit(1)
447+
442448
if (not pytest_args) and (not tests):
443-
pytest_args = (package,)
444-
if pytest_args == (None,):
445-
print(
446-
"Please specify `package = packagename` under `tool.spin` section of `pyproject.toml`"
447-
)
448-
sys.exit(1)
449+
tests = package
449450

450451
site_path = _set_pythonpath()
451452
if site_path:
@@ -494,12 +495,9 @@ def test(
494495
else:
495496
cmd = ["pytest"]
496497

497-
cwd = os.getcwd()
498498
pytest_p = _run(
499-
cmd + ([f"--rootdir={site_path}"] if site_path else []) + list(pytest_args),
500-
cwd=site_path,
499+
cmd + list(pytest_args),
501500
)
502-
os.chdir(cwd)
503501

504502
if gcov:
505503
# Verify the tools are present

0 commit comments

Comments
 (0)