1
0
mirror of https://github.com/scrapy/scrapy.git synced 2025-02-23 17:03:40 +00:00

Twisted's unittest.Testcase assertRaiess can't be used as context manager

This commit is contained in:
Daniel Graña 2018-08-15 08:54:18 -03:00
parent a304d6b692
commit 4eaf8690b1

View File

@ -143,9 +143,8 @@ class CrawlerRunnerTestCase(BaseCrawlerTest):
settings = Settings({
'SPIDER_LOADER_CLASS': 'tests.test_crawler.SpiderLoaderWithWrongInterface'
})
with warnings.catch_warnings(record=True) as w, \
self.assertRaises(AttributeError):
CrawlerRunner(settings)
with warnings.catch_warnings(record=True) as w:
self.assertRaises(AttributeError, CrawlerRunner, settings)
self.assertEqual(len(w), 1)
self.assertIn("SPIDER_LOADER_CLASS", str(w[0].message))
self.assertIn("scrapy.interfaces.ISpiderLoader", str(w[0].message))