import warnings
import unittest

from scrapy.crawler import Crawler
from scrapy.settings import Settings
from scrapy.utils.spider import DefaultSpider
from scrapy.utils.misc import load_object


class CrawlerTestCase(unittest.TestCase):

    def setUp(self):
        self.crawler = Crawler(DefaultSpider, Settings())

    def test_deprecated_attribute_spiders(self):
        with warnings.catch_warnings(record=True) as w:
            spiders = self.crawler.spiders
            self.assertEqual(len(w), 1)
            self.assertIn("Crawler.spiders", str(w[0].message))
            sm_cls = load_object(self.crawler.settings['SPIDER_MANAGER_CLASS'])
            self.assertIsInstance(spiders, sm_cls)

            self.crawler.spiders
            self.assertEqual(len(w), 1, "Warn deprecated access only once")

@@ -26,16 +26,52 @@
 ittest%0A%0A
+from twisted.internet import defer%0A%0A
 from scr
@@ -96,16 +96,31 @@
  Crawler
+, CrawlerRunner
 %0Afrom sc
@@ -771,32 +771,32 @@
 crawler.spiders%0A
-
             self
@@ -855,8 +855,883 @@
  once%22)%0A
+%0A%0Aclass CrawlerRunnerTest(unittest.TestCase):%0A%0A    def setUp(self):%0A        self.crawler_runner = CrawlerRunner(Settings())%0A%0A    @defer.inlineCallbacks%0A    def test_populate_spidercls_settings(self):%0A        spider_settings = %7B'TEST1': 'spider', 'TEST2': 'spider'%7D%0A        project_settings = %7B'TEST1': 'project', 'TEST3': 'project'%7D%0A%0A        class CustomSettingsSpider(DefaultSpider):%0A            custom_settings = spider_settings%0A%0A        self.crawler_runner.settings.setdict(project_settings,%0A                                             priority='project')%0A%0A        yield self.crawler_runner.crawl(CustomSettingsSpider)%0A        crawler = self.crawler_runner.crawlers.pop()%0A        self.assertEqual(crawler.settings.get('TEST1'), 'spider')%0A        self.assertEqual(crawler.settings.get('TEST2'), 'spider')%0A        self.assertEqual(crawler.settings.get('TEST3'), 'project')%0A

Test verifying that CrawlerRunner populates spider class settings