[PR #4907] [Other] a direct run of tools/test_strata_mcp.py runs every test (Fix #4906) #5244

Open
opened 2026-11-07 16:33:45 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/4907
Author: @XiaoBinGan
Created: 11/1/2026
Status: 🔄 Open

Base: main ← Head: fix/test-mcp-main-guard-last


📝 Commits (1)

  • 11eab2b Fix #4906: a direct run of tools/test_strata_mcp.py runs every test

📊 Changes

1 file changed (+4 additions, -4 deletions)

View changed files

📝 tools/test_strata_mcp.py (+4 -4)

📄 Description

Problem and result

tools/test_strata_mcp.py stopped its own run before the end when executed directly: the
if __name__ == "__main__": unittest.main() block sat at line 937 of 1112, and the last three test classes
(RemoveMissingFilesTest, DiskUsageTest, DraftLayerAndCancel) were appended after it in later commits
(917d2fc3, 31030b17). unittest.main() only collects the classes defined at the moment it runs, so a direct run
ran 45 of the file's 52 tests and silently skipped the other 7 — the delete-already-gone, disk-usage and draft-layer
checks.

before: python tools/test_strata_mcp.py            -> Ran 45 tests
        python tools/test_strata_mcp.py DiskUsageTest
                                                   -> AttributeError: module '__main__' has no attribute 'DiskUsageTest'
after:  python tools/test_strata_mcp.py            -> Ran 52 tests
        python tools/test_strata_mcp.py DiskUsageTest -> Ran 3 tests, OK

#4906 — the report I opened for this, with the same counts. A test-harness fix, not a behaviour change; no scope
agreement was asked for.

Approach

  • The if __name__ == "__main__": unittest.main() block moves from the middle of the file to the end, after
    DraftLayerAndCancel, so every class in the file is defined before unittest collects them.
  • No test class, assertion or fixture changes: this is only where the block sits. python -m unittest tools.test_strata_mcp and python -m pytest tools/test_strata_mcp.py already collected all 52 classes and behave
    the same after the move.

Validation

Passed: the previously unreachable classes on the branch, python tools/test_strata_mcp.py DiskUsageTest:
Ran 3 tests, OK; python tools/test_strata_mcp.py RemoveMissingFilesTest: Ran 1 test, OK.

Passed: the full direct run on the branch, python tools/test_strata_mcp.py: Ran 52 tests, 1 failure — the
MacCatalog::test_deepseek_on_a_mac_offers_the_two_sets_that_were_run_with_the_mac_words check, which already fails
on unmodified main under pytest and is tracked separately as #4904 (fix in #4905). The 7 tests this change puts
back all pass.

Passed: python -m pytest tools/test_strata_mcp.py -q on the branch still collects the same 52 tests (same
result as main: 1 failed, 51 passed, the #4904 check).

Failed: on unmodified main, python tools/test_strata_mcp.py → Ran 45 tests, and
python tools/test_strata_mcp.py DiskUsageTest → AttributeError: module '__main__' has no attribute 'DiskUsageTest'. That is the A/B.

Not run: the other tools' test files were not changed by this.

Limits

  • The file's documented invocation (python -m unittest tools/test_strata_mcp.py -v) already ran all 52 tests; this
    fixes the direct run that the other tools/test_*.py files use, which is where the 7 were missing.
  • The one remaining failure of a direct run is the stale Mac expectation tracked in #4904 and fixed in #4905; it is
    not part of this change, and the direct run reports it exactly as the pytest run does.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/4907 **Author:** [@XiaoBinGan](https://github.com/XiaoBinGan) **Created:** 11/1/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/test-mcp-main-guard-last` --- ### 📝 Commits (1) - [`11eab2b`](https://github.com/Niko1221/Strata/commit/11eab2ba4e7cb7c047ebd8e487093b2c2dd80fcd) Fix #4906: a direct run of tools/test_strata_mcp.py runs every test ### 📊 Changes **1 file changed** (+4 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `tools/test_strata_mcp.py` (+4 -4) </details> ### 📄 Description ## Problem and result `tools/test_strata_mcp.py` stopped its own run before the end when executed directly: the `if __name__ == "__main__": unittest.main()` block sat at line 937 of 1112, and the last three test classes (`RemoveMissingFilesTest`, `DiskUsageTest`, `DraftLayerAndCancel`) were appended after it in later commits (`917d2fc3`, `31030b17`). `unittest.main()` only collects the classes defined at the moment it runs, so a direct run ran 45 of the file's 52 tests and silently skipped the other 7 — the delete-already-gone, disk-usage and draft-layer checks. ```text before: python tools/test_strata_mcp.py -> Ran 45 tests python tools/test_strata_mcp.py DiskUsageTest -> AttributeError: module '__main__' has no attribute 'DiskUsageTest' after: python tools/test_strata_mcp.py -> Ran 52 tests python tools/test_strata_mcp.py DiskUsageTest -> Ran 3 tests, OK ``` ## Related discussion #4906 — the report I opened for this, with the same counts. A test-harness fix, not a behaviour change; no scope agreement was asked for. ## Approach - The `if __name__ == "__main__": unittest.main()` block moves from the middle of the file to the end, after `DraftLayerAndCancel`, so every class in the file is defined before unittest collects them. - No test class, assertion or fixture changes: this is only where the block sits. `python -m unittest tools.test_strata_mcp` and `python -m pytest tools/test_strata_mcp.py` already collected all 52 classes and behave the same after the move. ## Validation **Passed:** the previously unreachable classes on the branch, `python tools/test_strata_mcp.py DiskUsageTest`: **Ran 3 tests, OK**; `python tools/test_strata_mcp.py RemoveMissingFilesTest`: **Ran 1 test, OK**. **Passed:** the full direct run on the branch, `python tools/test_strata_mcp.py`: **Ran 52 tests**, 1 failure — the `MacCatalog::test_deepseek_on_a_mac_offers_the_two_sets_that_were_run_with_the_mac_words` check, which already fails on unmodified `main` under pytest and is tracked separately as #4904 (fix in #4905). The 7 tests this change puts back all pass. **Passed:** `python -m pytest tools/test_strata_mcp.py -q` on the branch still collects the same 52 tests (same result as `main`: 1 failed, 51 passed, the #4904 check). **Failed:** on unmodified `main`, `python tools/test_strata_mcp.py` → **Ran 45 tests**, and `python tools/test_strata_mcp.py DiskUsageTest` → `AttributeError: module '__main__' has no attribute 'DiskUsageTest'`. That is the A/B. **Not run:** the other tools' test files were not changed by this. ## Limits - The file's documented invocation (`python -m unittest tools/test_strata_mcp.py -v`) already ran all 52 tests; this fixes the direct run that the other `tools/test_*.py` files use, which is where the 7 were missing. - The one remaining failure of a direct run is the stale Mac expectation tracked in #4904 and fixed in #4905; it is not part of this change, and the direct run reports it exactly as the pytest run does. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#5244
No description provided.