style(tests): fix ruff lint errors in new snapshot/fallback/retry tests
Some checks are pending
Some checks are pending
This commit is contained in:
parent
4d2603cdd5
commit
a948639eca
4 changed files with 15 additions and 16 deletions
|
|
@ -12,8 +12,6 @@ mcp_production.py and x402.py into sub-packages.
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
class TestMCPPublicSurface:
|
||||
"""The mcp_production shim must expose the same public API as before."""
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ class TestRetryWithScraper:
|
|||
@pytest.mark.anyio
|
||||
async def test_retry_exhausts_and_raises(self, scraper_with_mocks):
|
||||
"""Retry exhausts attempts and re-raises."""
|
||||
s, mocks = scraper_with_mocks
|
||||
s, _mocks = scraper_with_mocks
|
||||
|
||||
async def scrape_or_raise(url: str) -> dict:
|
||||
result = await s.scrape(url)
|
||||
|
|
@ -98,7 +98,7 @@ class TestRetryWithScraper:
|
|||
raise RuntimeError(result.get("error", "scrape failed"))
|
||||
return result
|
||||
|
||||
with pytest.raises(RuntimeError, match="scrape failed|_failed|circuit_open"):
|
||||
with pytest.raises(RuntimeError, match=r"scrape failed|_failed|circuit_open"):
|
||||
await async_retry(scrape_or_raise, "https://example.com/page", config=BASE_CFG)
|
||||
|
||||
|
||||
|
|
@ -201,16 +201,16 @@ class TestDomainTierMemoryWithRetry:
|
|||
@pytest.mark.anyio
|
||||
async def test_domain_memory_used_on_retry(self, fresh_registry, scraper_with_mocks):
|
||||
"""After domain learns best tier, prefers it."""
|
||||
s, mocks = scraper_with_mocks
|
||||
s, _mocks = scraper_with_mocks
|
||||
fresh_registry.record_domain_tier_result("example.com", "archive", success=True, latency=0.1)
|
||||
html = _valid_html("archive content")
|
||||
mocks["_tier_archive"].return_value = html
|
||||
mocks["_tier_direct"].return_value = _valid_html("direct")
|
||||
_mocks["_tier_archive"].return_value = html
|
||||
_mocks["_tier_direct"].return_value = _valid_html("direct")
|
||||
|
||||
result = await s.scrape("https://example.com/page")
|
||||
assert result["status"] == "ok"
|
||||
mocks["_tier_archive"].assert_awaited()
|
||||
mocks["_tier_direct"].assert_not_awaited()
|
||||
_mocks["_tier_archive"].assert_awaited()
|
||||
_mocks["_tier_direct"].assert_not_awaited()
|
||||
|
||||
|
||||
class TestGracefulDegradation:
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ from __future__ import annotations
|
|||
from unittest.mock import AsyncMock
|
||||
|
||||
import pytest
|
||||
import resilience
|
||||
|
||||
import resilience
|
||||
from retry import (
|
||||
BackoffStrategy,
|
||||
Jitter,
|
||||
|
|
|
|||
|
|
@ -1,14 +1,20 @@
|
|||
"""Tests for ultimate scraper fallback chain."""
|
||||
|
||||
# SPDX-License-Identifier: MIT
|
||||
# Copyright (c) 2026 Rug Munch Media LLC
|
||||
#
|
||||
# Part of Pry — https://git.rugmunch.io/RugMunchMedia/pryscraper
|
||||
# Licensed under MIT. See LICENSE.
|
||||
"""Tests for ultimate scraper fallback chain."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from contextlib import ExitStack
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
import resilience
|
||||
from ultimate_scraper import UltimateScraper
|
||||
|
||||
|
||||
def _clear_registry() -> None:
|
||||
|
|
@ -22,10 +28,6 @@ def _clear_registry() -> None:
|
|||
cb.last_failure_at = 0.0
|
||||
cb.half_open_attempts = 0
|
||||
|
||||
import pytest
|
||||
|
||||
from ultimate_scraper import UltimateScraper
|
||||
|
||||
|
||||
_TIER_ALL = [
|
||||
"_tier_direct", "_tier_tls_fingerprint", "_tier_cloudscraper",
|
||||
|
|
@ -34,7 +36,6 @@ _TIER_ALL = [
|
|||
"_tier_archive", "_tier_google_cache", "_tier_tor",
|
||||
]
|
||||
|
||||
|
||||
def test_ultimate_init() -> None:
|
||||
s = UltimateScraper()
|
||||
assert s is not None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue