mirror of https://github.com/scrapy/scrapy.git
Fix expectations for old Twisted
This commit is contained in:
parent
fdba9843bb
commit
9726538cec
|
|
@ -2,7 +2,9 @@ from asyncio import sleep
|
|||
|
||||
import pytest
|
||||
from testfixtures import LogCapture
|
||||
from twisted import version as TWISTED_VERSION
|
||||
from twisted.internet.defer import Deferred
|
||||
from twisted.python.versions import Version
|
||||
from twisted.trial.unittest import TestCase
|
||||
|
||||
from scrapy import Spider, signals
|
||||
|
|
@ -21,6 +23,8 @@ ASYNC_GEN_ERROR_MINIMUM_SECONDS = ExecutionEngine._SLOT_HEARTBEAT_INTERVAL + 0.0
|
|||
ITEM_A = {"id": "a"}
|
||||
ITEM_B = {"id": "b"}
|
||||
|
||||
TWISTED_KEEPS_TRACEBACKS = TWISTED_VERSION >= Version("twisted", 24, 10, 0)
|
||||
|
||||
|
||||
def twisted_sleep(seconds):
|
||||
from twisted.internet import reactor
|
||||
|
|
@ -172,4 +176,9 @@ class MainTestCase(TestCase):
|
|||
):
|
||||
await self._test_spider(TestSpider, [])
|
||||
|
||||
assert "in start_requests\n raise RuntimeError" in str(log), log
|
||||
if TWISTED_KEEPS_TRACEBACKS:
|
||||
assert "in start_requests\n raise RuntimeError" in str(log), log
|
||||
else:
|
||||
assert "in _process_next_spider_start_yield\n item_or_request =" in str(
|
||||
log
|
||||
), log
|
||||
|
|
|
|||
Loading…
Reference in New Issue