test: reset upstream cooldowns between all tests

This commit is contained in:
9qeklajc
2026-09-27 11:29:59 +02:00
parent ca4e93a819
commit e9db5ffd30
2 changed files with 11 additions and 8 deletions
+10
View File
@@ -31,3 +31,13 @@ def _isolate_redemption_negative_cache() -> Iterator[None]:
redemption_negative_cache.clear() redemption_negative_cache.clear()
yield yield
redemption_negative_cache.clear() redemption_negative_cache.clear()
@pytest.fixture(autouse=True)
def _isolate_upstream_cooldowns() -> Iterator[None]:
"""Clear process-wide upstream cooldowns so one test's failures can't skip providers in the next."""
from routstr.upstream.cooldown import reset_cooldowns
reset_cooldowns()
yield
reset_cooldowns()
+1 -8
View File
@@ -11,7 +11,7 @@ import pytest
from routstr.core.exceptions import UpstreamError from routstr.core.exceptions import UpstreamError
from routstr.core.settings import settings from routstr.core.settings import settings
from routstr.upstream.cooldown import is_cooling_down, record_failure, reset_cooldowns from routstr.upstream.cooldown import is_cooling_down, record_failure
from routstr.upstream.stream_timeout import open_guarded_stream from routstr.upstream.stream_timeout import open_guarded_stream
@@ -33,13 +33,6 @@ async def _stalls_after_first() -> AsyncIterator[bytes]:
yield b"never delivered" yield b"never delivered"
@pytest.fixture(autouse=True)
def _clean_cooldowns() -> Any:
reset_cooldowns()
yield
reset_cooldowns()
@pytest.fixture @pytest.fixture
def fast_timeouts(monkeypatch: pytest.MonkeyPatch) -> None: def fast_timeouts(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setattr(settings, "upstream_first_token_timeout_seconds", 0.01) monkeypatch.setattr(settings, "upstream_first_token_timeout_seconds", 0.01)