Skip to content

test(tags): isolate warning capture from ancestor handlers - #7736

Open
r266-tech wants to merge 1 commit into
volcengine:mainfrom
r266-tech:codex/search-tags-warning-capture
Open

r266-tech wants to merge 1 commit into
volcengine:mainfrom
r266-tech:codex/search-tags-warning-capture

Conversation

@r266-tech

Copy link
Copy Markdown
Contributor

Description

The two search-tag warning tests attach caplog.handler directly to openviking.utils.tags. When logging capture is also installed on an ancestor logger, the same LogRecord reaches the capture handler twice. The existing one-warning assertions then fail even though normalization emitted one warning.

Disable propagation with monkeypatch while each test uses its direct capture handler. The fixture restores the original setting after the test; all normalization results, warning counts and warning-content assertions remain in place.

Human Involvement

  • A human participated in the implementation or review loop
  • This PR was generated entirely by AI agents without human participation in the loop

Related Issue

No issue. Reproduced on current main@f9bf90b3 through the existing tests. #6420 proposes removing these warning emissions; this change fixes capture of the current warning behavior independently.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test update

Changes Made

  • Scope logger.propagate = False to the two existing tests using the monkeypatch fixture.
  • Keep direct capture and its existing handler cleanup.

Testing

On macOS arm64 / Python 3.14.10 with the published OpenViking 0.5.5 native component, synthetic local configuration and no model calls:

LITELLM_LOCAL_MODEL_COST_MAP=True .venv/bin/python -m pytest tests/unit/test_search_tags_filter.py -o addopts= -q
# 27 passed

LITELLM_LOCAL_MODEL_COST_MAP=True .venv/bin/python -m pytest tests/server/test_mcp_endpoint.py::test_get_ctx_returns_set_context tests/unit/test_search_tags_filter.py -o addopts= -q
# main: 2 failed, 26 passed; patch: 28 passed

.venv/bin/python -m ruff check tests/unit/test_search_tags_filter.py
.venv/bin/python -m ruff format --check tests/unit/test_search_tags_filter.py
.venv/bin/python -m mypy tests/unit/test_search_tags_filter.py --follow-imports=silent
git diff --check

All listed patch checks pass. A temporary diagnostic confirmed that each failing base test captured two references to one distinct LogRecord; with the patch, each captures one record. The diagnostic is not part of the change. Seven existing dependency deprecation warnings remain. The full Python suite was not run.

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes (focused checks above)
  • I have tested this on the following platforms:
    • Linux
    • macOS
    • Windows

Checklist

  • My code follows the project's coding style
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Additional Notes

Only the two existing test setups change. There is no runtime or public-interface change.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant