From 38610a9e8ef9f938c4a0d52da70da0e0411eb87f Mon Sep 17 00:00:00 2001 From: Andrey Rakhmatullin Date: Fri, 17 Jul 2026 20:39:05 +0500 Subject: [PATCH] Don't assume a single log message. --- tests/test_extension_debug.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/test_extension_debug.py b/tests/test_extension_debug.py index 42d78688f..a54807c1c 100644 --- a/tests/test_extension_debug.py +++ b/tests/test_extension_debug.py @@ -103,11 +103,14 @@ async def test_stacktracedump_dumps_on_signal(caplog: pytest.LogCaptureFixture) crawler = get_crawler(spidercls=SignalSpider, settings_dict=settings) with caplog.at_level(logging.INFO, logger="scrapy.extensions.debug"): await crawler.crawl_async() - assert len(caplog.records) == 1 - message = caplog.records[0].getMessage() - assert "Dumping stack trace and engine status" in message - assert "engine.spider.name" in message - assert "signal_spider" in message + for r in caplog.records: + message = r.getMessage() + if "Dumping stack trace and engine status" in message: + assert "Dumping stack trace and engine status" in message + assert "engine.spider.name" in message + assert "signal_spider" in message + return + raise AssertionError("No stack trace dump log message found") @pytest.mark.skipif(sys.platform == "win32", reason="SIGUSR2 is POSIX-only")