'Test whether errors happening anywhere in Crawler.crawl() are properly
reported (and not somehow swallowed) after a graceful engine shutdown.
The errors should not come from within Scrapy\'s core but from within
spiders/middlewares/etc., e.g. raised in Spider.start_requests(),
SpiderMiddleware.process_start_requests(), etc.'

@defer.inlineCallbacks
def test_graceful_crawl_error_handling(self):

    class TestError(Exception, ):
        pass
    class FaultySpider(SimpleSpider, ):
        def start_requests(self):
            raise TestError
    crawler = self.runner.create_crawler(FaultySpider)
    (yield self.assertFailure(crawler.crawl(), TestError))
    self.assertFalse(crawler.crawling)
