Skip to content

Commit cc2f3e1

Browse files
committed
TST a test case to show custom_settings doesn't always work
1 parent d52cf8b commit cc2f3e1

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/test_crawler.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import warnings
22
import unittest
33

4+
import scrapy
45
from scrapy.crawler import Crawler, CrawlerRunner, CrawlerProcess
56
from scrapy.settings import Settings, default_settings
67
from scrapy.spiderloader import SpiderLoader
78
from scrapy.utils.spider import DefaultSpider
89
from scrapy.utils.misc import load_object
10+
from scrapy.extensions.throttle import AutoThrottle
911

1012

1113
class CrawlerTestCase(unittest.TestCase):
@@ -52,6 +54,18 @@ def test_crawler_accepts_dict(self):
5254
self.assertIsInstance(crawler.settings, Settings)
5355

5456

57+
class SpiderSettingsTestCase(unittest.TestCase):
58+
def test_spider_custom_settings(self):
59+
class MySpider(scrapy.Spider):
60+
name = 'spider'
61+
custom_settings = {
62+
'AUTOTHROTTLE_ENABLED': True
63+
}
64+
65+
crawler = Crawler(MySpider, {})
66+
enabled_exts = [e.__class__ for e in crawler.extensions.middlewares]
67+
self.assertIn(AutoThrottle, enabled_exts)
68+
5569

5670
class SpiderLoaderWithWrongInterface(object):
5771

0 commit comments

Comments
 (0)