diff --git a/spin/cmds/meson.py b/spin/cmds/meson.py index 7e18b77..c94f54d 100644 --- a/spin/cmds/meson.py +++ b/spin/cmds/meson.py @@ -275,12 +275,20 @@ def test(ctx, pytest_args, n_jobs, tests, verbose, coverage=False): site_path = _set_pythonpath() # Sanity check that library built properly + # + # We do this because `pytest` swallows exception messages originating from `conftest.py`. + # This can sometimes suppress useful information raised by the package on init. if sys.version_info[:2] >= (3, 11): p = _run([sys.executable, "-P", "-c", f"import {package}"], sys_exit=False) - if p.returncode != 0: - print(f"As a sanity check, we tried to import {package}.") - print("Stopping. Please investigate the build error.") - sys.exit(1) + else: + p = _run( + [sys.executable, "-c", f"import sys; del sys.path[0]; import {package}"], + sys_exit=False, + ) + if p.returncode != 0: + print(f"As a sanity check, we tried to import {package}.") + print("Stopping. Please investigate the build error.") + sys.exit(1) if (n_jobs != "1") and ("-n" not in pytest_args): pytest_args = ("-n", str(n_jobs)) + pytest_args