MCPcopy
hub / github.com/scrapy/scrapy / get_mwman

Method get_mwman

tests/test_downloadermiddleware.py:30–39  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

28 # should be a fixture but async fixtures that use Futures are problematic with pytest-twisted
29 @asynccontextmanager
30 async def get_mwman(self) -> AsyncGenerator[DownloaderMiddlewareManager]:
31 crawler = get_crawler(Spider, self.settings_dict)
32 crawler.spider = crawler._create_spider("foo")
33 mwman = DownloaderMiddlewareManager.from_crawler(crawler)
34 crawler.engine = crawler._create_engine()
35 await crawler.engine.open_spider_async()
36 try:
37 yield mwman
38 finally:
39 await crawler.engine.close_spider_async()
40
41 @staticmethod
42 async def _download(

Calls 6

get_crawlerFunction · 0.90
_create_spiderMethod · 0.80
_create_engineMethod · 0.80
from_crawlerMethod · 0.45
open_spider_asyncMethod · 0.45
close_spider_asyncMethod · 0.45

Tested by

no test coverage detected