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.
This commit is contained in:
mayank-dev-15 2026-07-04 16:33:12 +05:30
parent e8cb5a03b3
commit bed79d0034
1 changed files with 7 additions and 4 deletions

View File

@ -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):