MCPcopy
hub / github.com/scrapy/scrapy / test_params

Function test_params

tests/test_downloaderslotssettings.py:89–110  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

87
88@coroutine_test
89async def test_params():
90 params = {
91 "concurrency": 1,
92 "delay": 2,
93 "randomize_delay": False,
94 }
95 settings = {
96 "DOWNLOAD_SLOTS": {
97 "example.com": params,
98 },
99 }
100 crawler = get_crawler(DefaultSpider, settings_dict=settings)
101 crawler.spider = crawler._create_spider()
102 downloader = Downloader(crawler)
103 request = Request("https://example.com")
104 _, actual = downloader._get_slot(request)
105 downloader.close()
106 expected = Slot(**params)
107 for param in params:
108 assert getattr(expected, param) == getattr(actual, param), (
109 f"Slot.{param}: {getattr(expected, param)!r} != {getattr(actual, param)!r}"
110 )
111
112
113@coroutine_test

Callers

nothing calls this directly

Calls 7

_get_slotMethod · 0.95
closeMethod · 0.95
get_crawlerFunction · 0.90
DownloaderClass · 0.90
RequestClass · 0.90
SlotClass · 0.90
_create_spiderMethod · 0.80

Tested by

no test coverage detected