1. Gregory Petukhov
  2. grab

Commits

Gregory Petukhov  committed 3287f8d

Fix Spider.setup_grab issue (#38)

  • Participants
  • Parent commits a7629bf
  • Branches default

Comments (0)

Files changed (2)

File grab/spider/base.py

View file
             out.write(self.render_stats())
 
     def setup_grab(self, **kwargs):
-        self.grab_config = kwargs
+        self.grab_config.update(**kwargs)
 
     def load_initial_urls(self):
         """

File test/spider.py

View file
         sp.add_task(Task('baz', BASE_URL))
         sp.run()
         self.assertEqual('xxx', sp.SAVED_ITEM)
+
+    def test_setup_grab(self):
+        """
+        Mulitple calls to `setup_grab` should accumulate changes in config object.
+        """
+        bot = self.SimpleSpider()
+        bot.setup_grab(log_dir='/tmp')
+        bot.setup_grab(timeout=30)
+        grab = bot.create_grab_instance()
+        self.assertEqual(grab.config['log_dir'], '/tmp')
+        self.assertEqual(grab.config['timeout'], 30)