Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

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

Daniel Graña4eaf8690b145
diff --git a/tests/test_crawler.py b/tests/test_crawler.py
index 0aeb12e58..268948a70 100644
--- a/tests/test_crawler.py
+++ b/tests/test_crawler.py
@@ -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))