rusackas opened a new pull request, #41911: URL: https://github.com/apache/superset/pull/41911
### SUMMARY `Python-Unit` is red on `master`. Six tests in `tests/unit_tests/mcp_service/semantic_layer/tool/test_list_metrics.py` fail with: ``` AttributeError: <function list_metrics at 0x...> does not have the attribute 'DatasetDAO' AttributeError: <function list_metrics at 0x...> does not have the attribute 'SemanticViewDAO' ``` **Root cause:** the tests patch the DAOs via the string path `"superset.mcp_service.semantic_layer.tool.list_metrics.DatasetDAO"` (and `SemanticViewDAO` / `db`). But `superset/mcp_service/semantic_layer/tool/__init__.py` re-exports the `list_metrics` **function** (`from .list_metrics import list_metrics`), so the `tool.list_metrics` *attribute* points at that function, shadowing the submodule of the same name. `mock.patch` resolves its target by walking attributes, lands on the function, and can't find `DatasetDAO` on it — hence the error. (It's the classic module/function name-collision trap.) **Fix:** patch through the already-imported module object with `patch.object(list_metrics_module, "DatasetDAO")`. The file already imports that module via `importlib` at the top (`list_metrics_module`) and its autouse fixture already patches through it — so this just makes the DAO/`db` patches consistent with the working pattern, resolving to the real submodule unambiguously. No production code changes. ### TESTING INSTRUCTIONS ``` pytest tests/unit_tests/mcp_service/semantic_layer/tool/test_list_metrics.py ``` Before: 6 failed / 8. After: **8 passed** (verified locally). `ruff format --check` and `ruff check` both clean. ### ADDITIONAL INFORMATION - [ ] Has associated issue: - [ ] Changes UI - [ ] Includes DB Migration - [ ] Introduces new feature or API - [ ] Removes existing feature or API Test-only change to unbreak `master` CI. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
