MCPcopy
hub / github.com/scrapy/scrapy / test_delay

Method test_delay

tests/test_downloaderslotssettings.py:72–85  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

70
71 @inline_callbacks_test
72 def test_delay(self):
73 crawler = get_crawler(DownloaderSlotsSettingsTestSpider)
74 yield crawler.crawl(mockserver=self.mockserver)
75 slots = crawler.engine.downloader.slots
76 times = crawler.spider.times
77 tolerance = 0.3
78
79 delays_real = {k: v[1] - v[0] for k, v in times.items()}
80 error_delta = {
81 k: 1 - min(delays_real[k], v.delay) / max(delays_real[k], v.delay)
82 for k, v in slots.items()
83 }
84
85 assert max(list(error_delta.values())) < tolerance
86
87
88@coroutine_test

Callers

nothing calls this directly

Calls 4

get_crawlerFunction · 0.90
itemsMethod · 0.80
valuesMethod · 0.80
crawlMethod · 0.45

Tested by

no test coverage detected