Narrow down TestEngine::test_short_timeout() expectations. (#6911)

This commit is contained in:
Andrey Rakhmatullin 2025-07-01 16:47:43 +05:00 committed by GitHub
parent 03fe7a6424
commit c9cdf0af3c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 2 deletions

View File

@ -135,6 +135,9 @@ class ExecutionEngine:
await maybe_deferred_to_future(
self.signals.send_catch_log_deferred(signal=signals.engine_started)
)
if _start_request_processing and self.spider is None:
# require an opened spider when not run in scrapy shell
return
self.running = True
self._closewait = Deferred()
if _start_request_processing:
@ -541,5 +544,6 @@ class ExecutionEngine:
dfd.addErrback(log_failure("Error while unassigning spider"))
dfd.addBoth(lambda _: self._spider_closed_callback(spider))
dfd.addErrback(log_failure("Error running spider_closed_callback"))
return dfd

View File

@ -509,7 +509,9 @@ class TestEngine(TestEngineBase):
finally:
timer.cancel()
assert b"Traceback" not in stderr, stderr
stderr_str = stderr.decode("utf-8")
assert "AttributeError" not in stderr_str, stderr_str
assert "AssertionError" not in stderr_str, stderr_str
def test_request_scheduled_signal(caplog):

View File

@ -112,7 +112,8 @@ class MainTestCase(TestCase):
with LogCapture(level=ERROR) as log:
await maybe_deferred_to_future(crawler.crawl())
assert not log.records
assert len(log.records) == 1
assert log.records[0].msg == "Error running spider_closed_callback"
finish_reason = crawler.stats.get_value("finish_reason")
assert finish_reason == "shutdown", f"{finish_reason=}"
expected_urls = []