Skip to content

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

TST a test case to show custom_settings doesn't always work

Mikhail Korobovcc2f3e1b46b6
diff --git a/tests/test_crawler.py b/tests/test_crawler.py
index 53f517c27..1c0804675 100644
--- a/tests/test_crawler.py
+++ b/tests/test_crawler.py
@@ -1,11 +1,13 @@
import warnings
import unittest
+import scrapy
from scrapy.crawler import Crawler, CrawlerRunner, CrawlerProcess
from scrapy.settings import Settings, default_settings
from scrapy.spiderloader import SpiderLoader
from scrapy.utils.spider import DefaultSpider
from scrapy.utils.misc import load_object
+from scrapy.extensions.throttle import AutoThrottle
class CrawlerTestCase(unittest.TestCase):
@@ -52,6 +54,18 @@ class CrawlerTestCase(unittest.TestCase):
self.assertIsInstance(crawler.settings, Settings)
+class SpiderSettingsTestCase(unittest.TestCase):
+ def test_spider_custom_settings(self):
+ class MySpider(scrapy.Spider):
+ name = 'spider'
+ custom_settings = {
+ 'AUTOTHROTTLE_ENABLED': True
+ }
+
+ crawler = Crawler(MySpider, {})
+ enabled_exts = [e.__class__ for e in crawler.extensions.middlewares]
+ self.assertIn(AutoThrottle, enabled_exts)
+
class SpiderLoaderWithWrongInterface(object):