mirror of https://github.com/scrapy/scrapy.git
Add testcase for catching exception from open_spider() from pipeline
This commit is contained in:
parent
7727d87f64
commit
61efacdd1f
|
|
@ -0,0 +1,11 @@
|
|||
"""
|
||||
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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue