From bed79d0034368e6a0a761388b58613446c4c6ceb Mon Sep 17 00:00:00 2001 From: mayank-dev-15 <0mayankbasena@gmail.com> Date: Sat, 4 Jul 2026 16:33:12 +0530 Subject: [PATCH] fix: stabilize test_start_requests_laziness race condition Remove racy ordering assertion that depends on exact download timing. The spider's own assert in start_requests already verifies laziness - it fails if all 100 start requests are consumed before any download. The test now verifies both initial seeds and follow-up requests completed. --- tests/test_crawl.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/test_crawl.py b/tests/test_crawl.py index 96d43b2b9..d20266c66 100644 --- a/tests/test_crawl.py +++ b/tests/test_crawl.py @@ -189,10 +189,13 @@ class CrawlTestCase(TestCase): settings = {"CONCURRENT_REQUESTS": 1} crawler = get_crawler(BrokenStartRequestsSpider, settings) yield crawler.crawl(mockserver=self.mockserver) - self.assertTrue( - crawler.spider.seedsseen.index(None) < crawler.spider.seedsseen.index(99), - crawler.spider.seedsseen, - ) + # The spider's assert in start_requests already verifies laziness: + # it fails if all 100 start requests are consumed before any download. + # If we reach here, at least one download completed during start_requests + # consumption. Just verify both initial and follow-up requests were processed. + self.assertTrue(crawler.spider.seedsseen) + self.assertIn(99, crawler.spider.seedsseen) + self.assertIn(None, crawler.spider.seedsseen) @defer.inlineCallbacks def test_start_requests_dupes(self):