Scrapy, a fast high-level web crawling & scraping framework for Python.
fixed backwards compatibility for SPIDER_MANAGER_CLASS option
Mikhail Korobovc3d3a9491412
diff --git a/scrapy/crawler.py b/scrapy/crawler.pyindex dab1043ec..b4706919a 100644--- a/scrapy/crawler.py+++ b/scrapy/crawler.py@@ -192,8 +192,8 @@ def _get_spider_loader(settings):'Please use SPIDER_LOADER_CLASS.',category=ScrapyDeprecationWarning, stacklevel=2)- cls_path = settings.get('SPIDER_LOADER_CLASS',- settings.get('SPIDER_MANAGER_CLASS'))+ cls_path = settings.get('SPIDER_MANAGER_CLASS',+ settings.get('SPIDER_LOADER_CLASS'))loader_cls = load_object(cls_path)verifyClass(ISpiderLoader, loader_cls)return loader_cls.from_settings(settings.frozencopy())diff --git a/tests/test_crawler.py b/tests/test_crawler.pyindex 50da01e73..6a282ed84 100644--- a/tests/test_crawler.py+++ b/tests/test_crawler.py@@ -5,6 +5,7 @@ from zope.interface.verify import DoesNotImplementfrom scrapy.crawler import Crawler, CrawlerRunnerfrom scrapy.settings import Settings, default_settings+from scrapy.spiderloader import SpiderLoaderfrom scrapy.utils.spider import DefaultSpiderfrom scrapy.utils.misc import load_object@@ -60,6 +61,10 @@ class SpiderLoaderWithWrongInterface(object):pass+class CustomSpiderLoader(SpiderLoader):+ pass++class CrawlerRunnerTestCase(unittest.TestCase):def test_spider_manager_verify_interface(self):@@ -87,3 +92,13 @@ class CrawlerRunnerTestCase(unittest.TestCase):self.assertIn("CrawlerRunner.spider_loader", str(w[0].message))sl_cls = load_object(runner.settings['SPIDER_LOADER_CLASS'])self.assertIsInstance(spiders, sl_cls)++ def test_spidermanager_deprecation(self):+ with warnings.catch_warnings(record=True) as w:+ runner = CrawlerRunner({+ 'SPIDER_MANAGER_CLASS': 'tests.test_crawler.CustomSpiderLoader'+ })+ self.assertIsInstance(runner.spider_loader, CustomSpiderLoader)+ self.assertEqual(len(w), 1)+ self.assertIn('Please use SPIDER_LOADER_CLASS', str(w[0].message))+