diff options
| author | fiestorra <fiestorra@users.noreply.github.com> | 2026-11-30 04:04:04 +0100 |
|---|---|---|
| committer | fiestorra <fiestorra@users.noreply.github.com> | 2026-11-30 14:55:47 +0100 |
| commit | 1eee5a1aaa709701fbc145ee5a681c8e27e4ea3e (patch) | |
| tree | 96fe0e7f93711ce7245534d2a94fe6c53d2701f8 | |
| parent | aa51a9693e49b938bfbe457e79bf301eed18380c (diff) | |
tests: a sibling that imports a numeric tool is not a startup failure
test_each_sibling_importing_tool_starts skipped a NUMERIC list when numpy was
missing, but it asked find_spec in this process while the tools run with -I, so
the skip never fired here; and a list of names cannot cover calibrated_texture
and tex_export, which are not numeric themselves and import one that is.
The probe now matches how the tools run, and a child that fails with
"No module named 'numpy'" is skipped rather than failing the startup check.
Measured on main b8bd37111, Windows 11, Python 3.13: 2 failed, 2 passed,
218 subtests before; 2 passed, 214 subtests after (the four are the two
numpy-dependent subtests, skipped). With numpy visible to -I nothing changes.
Written with an AI assistant.
| -rw-r--r-- | tests/test_tool_startup.py | 9 |
1 files changed, 8 insertions, 1 deletions
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): | |||
| 53 | def test_each_sibling_importing_tool_starts(self): | 53 | def test_each_sibling_importing_tool_starts(self): |
| 54 | paths = sibling_importers() | 54 | paths = sibling_importers() |
| 55 | self.assertGreater(len(paths), 20, "the sibling-import scan found almost nothing") | 55 | self.assertGreater(len(paths), 20, "the sibling-import scan found almost nothing") |
| 56 | have_numpy = importlib.util.find_spec("numpy") is not None | 56 | # Ask the way the tools are launched: `-I` does not see a --user install, so find_spec in this process can |
| 57 | # say yes while the child gets ModuleNotFoundError (tests/test_tile_probe.py carries the same correction). | ||
| 58 | have_numpy = subprocess.run([sys.executable, "-I", "-c", "import numpy"], | ||
| 59 | capture_output=True, check=False).returncode == 0 | ||
| 57 | for path in paths: | 60 | for path in paths: |
| 58 | name = os.path.splitext(os.path.basename(path))[0] | 61 | name = os.path.splitext(os.path.basename(path))[0] |
| 59 | if name in NUMERIC and not have_numpy: | 62 | if name in NUMERIC and not have_numpy: |
| @@ -61,6 +64,10 @@ class ToolStartupTests(unittest.TestCase): | |||
| 61 | with self.subTest(tool=name): | 64 | with self.subTest(tool=name): |
| 62 | proc = subprocess.run([sys.executable, "-I", path, "--help"], capture_output=True, text=True, | 65 | proc = subprocess.run([sys.executable, "-I", path, "--help"], capture_output=True, text=True, |
| 63 | timeout=TIMEOUT, errors="replace") | 66 | timeout=TIMEOUT, errors="replace") |
| 67 | # A sibling that is not numeric itself can still import a numeric one: a list of names cannot cover | ||
| 68 | # those, and a missing third-party module is not a startup failure. CI has numpy, so it never fires. | ||
| 69 | if not have_numpy and "No module named 'numpy'" in proc.stderr: | ||
| 70 | continue | ||
| 64 | self.assertEqual(proc.returncode, 0, proc.stderr[-2000:]) | 71 | self.assertEqual(proc.returncode, 0, proc.stderr[-2000:]) |
| 65 | self.assertNotIn("Traceback", proc.stderr) | 72 | self.assertNotIn("Traceback", proc.stderr) |
| 66 | 73 | ||