mirror of https://github.com/scrapy/scrapy.git
Merge branch 'master' of github.com:StasDeep/scrapy into feature/issue-3364
This commit is contained in:
commit
8bc536d88b
|
|
@ -88,7 +88,7 @@ class ContractsManager(object):
|
|||
|
||||
def eb_wrapper(failure):
|
||||
case = _create_testcase(method, 'errback')
|
||||
exc_info = failure.value, failure.type, failure.getTracebackObject()
|
||||
exc_info = failure.type, failure.value, failure.getTracebackObject()
|
||||
results.addError(case, exc_info)
|
||||
|
||||
request.callback = cb_wrapper
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
from unittest import TextTestResult
|
||||
|
||||
from twisted.python import failure
|
||||
from twisted.trial import unittest
|
||||
|
||||
from scrapy.spidermiddlewares.httperror import HttpError
|
||||
from scrapy.spiders import Spider
|
||||
from scrapy.http import Request
|
||||
from scrapy.item import Item, Field
|
||||
|
|
@ -236,3 +238,18 @@ class ContractsManagerTest(unittest.TestCase):
|
|||
|
||||
self.conman.from_spider(CustomContractFailSpider(), self.results)
|
||||
self.should_error()
|
||||
|
||||
def test_errback(self):
|
||||
spider = TestSpider()
|
||||
response = ResponseMock()
|
||||
|
||||
try:
|
||||
raise HttpError(response, 'Ignoring non-200 response')
|
||||
except HttpError:
|
||||
failure_mock = failure.Failure()
|
||||
|
||||
request = self.conman.from_method(spider.returns_request, self.results)
|
||||
request.errback(failure_mock)
|
||||
|
||||
self.assertFalse(self.results.failures)
|
||||
self.assertTrue(self.results.errors)
|
||||
|
|
|
|||
Loading…
Reference in New Issue