restore http10 as default handler and skip tests if http1.1 is not supported

This commit is contained in:
Daniel Graña 2013-06-04 16:36:21 -03:00
parent 8b0c9466d6
commit bb806fa0f8
3 changed files with 22 additions and 5 deletions

View File

@ -53,8 +53,8 @@ DOWNLOAD_DELAY = 0
DOWNLOAD_HANDLERS = {}
DOWNLOAD_HANDLERS_BASE = {
'file': 'scrapy.core.downloader.handlers.file.FileDownloadHandler',
'http': 'scrapy.core.downloader.handlers.http11.Http11DownloadHandler',
'https': 'scrapy.core.downloader.handlers.http11.Http11DownloadHandler',
'http': 'scrapy.core.downloader.handlers.http.HttpDownloadHandler',
'https': 'scrapy.core.downloader.handlers.http.HttpDownloadHandler',
's3': 'scrapy.core.downloader.handlers.s3.S3DownloadHandler',
}

View File

@ -1,4 +1,5 @@
import os
import twisted
from twisted.trial import unittest
from twisted.protocols.policies import WrappingFactory
@ -143,6 +144,9 @@ class Http11TestCase(HttpTestCase):
"""HTTP 1.1 test case"""
download_handler_cls = Http11DownloadHandler
if twisted.__version__.split('.') < (11, 1, 0):
skip = 'HTTP1.1 not supported in twisted < 11.1.0'
class UriResource(resource.Resource):
"""Return the full uri that was requested"""
@ -198,6 +202,9 @@ class HttpProxyTestCase(unittest.TestCase):
class Http11ProxyTestCase(HttpProxyTestCase):
download_handler_cls = Http11DownloadHandler
if twisted.__version__.split('.') < (11, 1, 0):
skip = 'HTTP1.1 not supported in twisted < 11.1.0'
class HttpDownloadHandlerMock(object):
def __init__(self, settings):

View File

@ -1,9 +1,19 @@
import twisted
if twisted.__version__.split('.') < (13, 0, 1):
from . import client, endpoints
else:
txver = twisted.__version__.split('.')
if txver > (13, 0, 0):
from twisted.web import client
from twisted.internet import endpoints
if txver >= (11, 1, 0):
from . import client, endpoints
else:
from scrapy.exceptions import NotSupported
class _Mocked(object):
def __init__(self, *args, **kw):
raise NotSupported('HTTP1.1 not supported')
class _Mock(object):
def __getattr__(self, name):
return _Mocked
client = endpoints = _Mock()
Agent = client.Agent