From ee8c5f7aa4486abf9dd7a2e225140745055e40ea Mon Sep 17 00:00:00 2001 From: Adrian Chaves Date: Fri, 26 Jun 2026 16:00:11 +0200 Subject: [PATCH] Fix two environment-specific test failures --- scrapy/throttling.py | 6 ++---- tests/test_engine.py | 1 + tests/test_throttling.py | 11 ----------- 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/scrapy/throttling.py b/scrapy/throttling.py index b46e192fa..f90a25dd8 100644 --- a/scrapy/throttling.py +++ b/scrapy/throttling.py @@ -800,11 +800,9 @@ class ThrottlingScopeManagerProtocol(Protocol): """ @classmethod - def from_crawler(cls, crawler: Crawler, config: dict[str, Any]) -> Self: - return cls(crawler, config) + def from_crawler(cls, crawler: Crawler, config: dict[str, Any]) -> Self: ... - def __init__(self, crawler: Crawler, config: dict[str, Any]) -> None: - pass + def __init__(self, crawler: Crawler, config: dict[str, Any]) -> None: ... def can_send(self, now: float | None = None, amount: float | None = None) -> float: """Return the number of seconds to wait before a request for this scope diff --git a/tests/test_engine.py b/tests/test_engine.py index 148a7f4e7..60d911009 100644 --- a/tests/test_engine.py +++ b/tests/test_engine.py @@ -673,6 +673,7 @@ class TestEngineThrottling: engine.unpause() assert engine.paused is False + @pytest.mark.requires_reactor # call_later() needs a reactor or asyncio loop def test_maybe_arm_throttling_wakeup_arms_timer(self, engine): scheduler = Mock() scheduler.has_pending_requests.return_value = True diff --git a/tests/test_throttling.py b/tests/test_throttling.py index 6ee4a49df..62efe29bb 100644 --- a/tests/test_throttling.py +++ b/tests/test_throttling.py @@ -816,17 +816,6 @@ class TestThrottlingManagerEdges: # The still-pending m2 event is discarded from its waiter list. assert m2._slot_waiters == [] - def test_scope_manager_protocol_defaults(self): - from scrapy.throttling import ThrottlingScopeManagerProtocol # noqa: PLC0415 - - class _Concrete(ThrottlingScopeManagerProtocol): - pass - - crawler = get_crawler() - # The protocol's default from_crawler()/__init__ are usable as-is. - instance = _Concrete.from_crawler(crawler, {"id": "example.com"}) - assert isinstance(instance, _Concrete) - @coroutine_test async def test_process_exception_applies_backoff(self): manager = _manager()