Scrapy, a fast high-level web crawling & scraping framework for Python.
Improve tests for start items. (#6770)
Andrey Rakhmatullin5dfe7cd7b87f
diff --git a/tests/test_crawl.py b/tests/test_crawl.pyindex b85f56909..b7a8a9628 100644--- a/tests/test_crawl.py+++ b/tests/test_crawl.py@@ -188,11 +188,18 @@ class TestCrawl(TestCase):@defer.inlineCallbacksdef test_start_requests_items(self):+ items = []++ def _on_item_scraped(item):+ items.append(item)+with LogCapture("scrapy", level=logging.ERROR) as log:crawler = get_crawler(StartRequestsItemSpider)+ crawler.signals.connect(_on_item_scraped, signals.item_scraped)yield crawler.crawl(mockserver=self.mockserver)assert len(log.records) == 0+ assert items == [{"name": "test item"}]@defer.inlineCallbacksdef test_start_requests_unsupported_output(self):@@ -201,11 +208,19 @@ class TestCrawl(TestCase):things fail when ItemAdapter is actually used on the correspondingnon-item object."""+ items = []++ def _on_item_scraped(item):+ items.append(item)+with LogCapture("scrapy", level=logging.ERROR) as log:crawler = get_crawler(StartRequestsGoodAndBadOutput)+ crawler.signals.connect(_on_item_scraped, signals.item_scraped)yield crawler.crawl(mockserver=self.mockserver)assert len(log.records) == 0+ assert len(items) == 3+ assert not any(isinstance(item, Request) for item in items)@defer.inlineCallbacksdef test_start_requests_laziness(self):