提交 61efacdd 编写于 作者: P Paul Tremberth

Add testcase for catching exception from open_spider() from pipeline

上级 7727d87f
"""
Some pipelines used for testing and benchmarking
"""
class ZeroDivisionErrorPipeline(object):
def open_spider(self, spider):
a = 1/0
def process_item(self, item, spider):
return item
......@@ -250,6 +250,18 @@ with multiples lines
yield self.assertFailure(crawler.crawl(), TestError)
self.assertFalse(crawler.crawling)
@defer.inlineCallbacks
def test_open_spider_error_on_faulty_pipeline(self):
settings = {
"ITEM_PIPELINES": {
"tests.pipelines.ZeroDivisionErrorPipeline": 300,
}
}
crawler = CrawlerRunner(settings).create_crawler(SimpleSpider)
yield self.assertFailure(
self.runner.crawl(crawler, "http://localhost:8998/status?n=200"),
ZeroDivisionError)
@defer.inlineCallbacks
def test_crawlerrunner_accepts_crawler(self):
crawler = self.runner.create_crawler(SimpleSpider)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册