tools tests: test_strata_mcp.py run directly runs all its tests (#4906)

unittest.main() sat before the last three test classes (RemoveMissingFilesTest,
DiskUsageTest, DraftLayerAndCancel), so `python tools/test_strata_mcp.py` ran 46
tests and stopped; pytest collected all of them. The __main__ block is now at the
end of the file. One of the nine tests that a direct run now reaches imports
strata_control, which pytest finds through its rootdir; the file now puts the repo
root on sys.path too, so a direct run and pytest see the same modules.
Test: run directly, 46 tests OK on 4864a4daa's successor 937fe7115 (9 never
ran); 55 tests OK here (1 skipped), the same 55 as `python -m unittest
tools.test_strata_mcp`.
This commit is contained in:
Niko1221 committed 2026-11-16 17:01:40 +01:00
1 parent 937fe71155
commit 0027d210b8
1 file changed
+5 -4
+5 -4
View File
@@ -24,6 +24,7 @@ from pathlib import Path
HERE = Path(__file__).resolve().parent
sys.path.insert(0, str(HERE))
sys.path.insert(1, str(HERE.parent)) # strata_control, as pytest's rootdir gives it, also when the file is run directly (#4906)
import strata_mcp as M # noqa: E402
FAKE_SETUP = r'''
@@ -1000,10 +1001,6 @@ class MixedGraphics(unittest.TestCase):
self.assertEqual(setup_config.UMA_WIN_RESERVE_MIB, 700)
if __name__ == "__main__":
unittest.main()
class RemoveMissingFilesTest(unittest.TestCase):
"""Deleting a model whose plan lists files that are already gone (or inside a folder removed earlier) is a success, not 'Some files could not be removed'."""
@@ -1198,3 +1195,7 @@ class DraftLayerAndCancel(unittest.TestCase):
for pid in (grand, top.pid):
subprocess.run(["taskkill", "/PID", str(pid), "/T", "/F"], capture_output=True)
top.wait(10)
if __name__ == "__main__":
unittest.main()