chore(V2): cleanup quality gate
- ruff: contextlib.suppress al posto di try/except/pass (client_registry, test_env_routing) - rimozione services/ legacy (residuo da git rm) - fix integration test fixture: rimosso sys.modules.pop che inquinava module references nei test successivi (test_audit, test_client_init_default_http) 254 test passano. Ruff: clean. Mypy: 68 warning preesistenti dal codice V1 migrato (strict=false). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -9,12 +9,12 @@ solo che il costruttore venga chiamato con i parametri corretti.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import contextlib
|
||||
import importlib
|
||||
|
||||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
|
||||
# ── Fixtures ────────────────────────────────────────────────────────────────
|
||||
|
||||
@pytest.fixture
|
||||
@@ -23,13 +23,6 @@ def app(monkeypatch):
|
||||
for k, v in _minimal_env().items():
|
||||
monkeypatch.setenv(k, v)
|
||||
|
||||
# Re-import fresco per evitare Settings cached con env vuoto
|
||||
import importlib
|
||||
import sys
|
||||
for mod_name in list(sys.modules.keys()):
|
||||
if "cerbero_mcp" in mod_name:
|
||||
sys.modules.pop(mod_name, None)
|
||||
|
||||
from cerbero_mcp.__main__ import _make_app
|
||||
from cerbero_mcp.settings import Settings
|
||||
return _make_app(Settings())
|
||||
@@ -58,12 +51,10 @@ def _spy_constructor(monkeypatch, module_path: str, cls_name: str, capture: dict
|
||||
def spy_init(self, *args, **kwargs):
|
||||
capture["args"] = args
|
||||
capture["kwargs"] = kwargs
|
||||
try:
|
||||
# Se il costruttore fallisce (network, SDK unavailable) non importa:
|
||||
# la capture è già avvenuta.
|
||||
with contextlib.suppress(Exception):
|
||||
real_init(self, *args, **kwargs)
|
||||
except Exception:
|
||||
# Se il costruttore fallisce (network, SDK unavailable) non importa:
|
||||
# la capture è già avvenuta.
|
||||
pass
|
||||
|
||||
monkeypatch.setattr(real_cls, "__init__", spy_init)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user