mirror of https://github.com/scrapy/scrapy.git
[test] Handle keyword args in CrawlSpider.parse
This commit is contained in:
parent
8d4948f6ca
commit
c54df8253a
|
|
@ -211,8 +211,9 @@ class CrawlSpiderWithParseMethod(MockServerSpider, CrawlSpider):
|
|||
url = self.mockserver.url("/alpayload")
|
||||
yield Request(url, method="POST", body=test_body)
|
||||
|
||||
def parse(self, response):
|
||||
self.logger.info('[parse] status %i', response.status)
|
||||
def parse(self, response, foo=None):
|
||||
self.logger.info('[parse] status %i (foo: %s)', response.status, foo)
|
||||
yield Request(self.mockserver.url("/status?n=202"), self.parse, cb_kwargs={"foo": "bar"})
|
||||
|
||||
|
||||
class CrawlSpiderWithErrback(CrawlSpiderWithParseMethod):
|
||||
|
|
|
|||
|
|
@ -316,8 +316,9 @@ class CrawlSpiderTestCase(TestCase):
|
|||
with LogCapture() as log:
|
||||
yield self.runner.join()
|
||||
|
||||
self.assertIn("[parse] status 200", str(log))
|
||||
self.assertIn("[parse] status 201", str(log))
|
||||
self.assertIn("[parse] status 200 (foo: None)", str(log))
|
||||
self.assertIn("[parse] status 201 (foo: None)", str(log))
|
||||
self.assertIn("[parse] status 202 (foo: bar)", str(log))
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def test_crawlspider_with_errback(self):
|
||||
|
|
@ -326,8 +327,9 @@ class CrawlSpiderTestCase(TestCase):
|
|||
with LogCapture() as log:
|
||||
yield self.runner.join()
|
||||
|
||||
self.assertIn("[parse] status 200", str(log))
|
||||
self.assertIn("[parse] status 201", str(log))
|
||||
self.assertIn("[parse] status 200 (foo: None)", str(log))
|
||||
self.assertIn("[parse] status 201 (foo: None)", str(log))
|
||||
self.assertIn("[parse] status 202 (foo: bar)", str(log))
|
||||
self.assertIn("[errback] status 404", str(log))
|
||||
self.assertIn("[errback] status 500", str(log))
|
||||
self.assertIn("[errback] status 501", str(log))
|
||||
|
|
|
|||
Loading…
Reference in New Issue