diff --git a/tests/test_tool_startup.py b/tests/test_tool_startup.py index eb1eb6509..341f4cf33 100644 --- a/tests/test_tool_startup.py +++ b/tests/test_tool_startup.py @@ -53,7 +53,10 @@ class ToolStartupTests(unittest.TestCase): def test_each_sibling_importing_tool_starts(self): paths = sibling_importers() self.assertGreater(len(paths), 20, "the sibling-import scan found almost nothing") - have_numpy = importlib.util.find_spec("numpy") is not None + # Ask the way the tools are launched: `-I` does not see a --user install, so find_spec in this process can + # say yes while the child gets ModuleNotFoundError (tests/test_tile_probe.py carries the same correction). + have_numpy = subprocess.run([sys.executable, "-I", "-c", "import numpy"], + capture_output=True, check=False).returncode == 0 for path in paths: name = os.path.splitext(os.path.basename(path))[0] if name in NUMERIC and not have_numpy: @@ -61,6 +64,10 @@ class ToolStartupTests(unittest.TestCase): with self.subTest(tool=name): proc = subprocess.run([sys.executable, "-I", path, "--help"], capture_output=True, text=True, timeout=TIMEOUT, errors="replace") + # A sibling that is not numeric itself can still import a numeric one: a list of names cannot cover + # those, and a missing third-party module is not a startup failure. CI has numpy, so it never fires. + if not have_numpy and "No module named 'numpy'" in proc.stderr: + continue self.assertEqual(proc.returncode, 0, proc.stderr[-2000:]) self.assertNotIn("Traceback", proc.stderr)