mirror of https://github.com/scrapy/scrapy.git
Fix two environment-specific test failures
This commit is contained in:
parent
aeb6b4763c
commit
ee8c5f7aa4
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Reference in New Issue