Scrapy, a fast high-level web crawling & scraping framework for Python.
fix import of test_downloader_handlers.py: use @implementer, move failing on py3 imports into corresponding tests
Konstantin Lopuhin32bb5b682a7c
diff --git a/scrapy/core/downloader/handlers/http11.py b/scrapy/core/downloader/handlers/http11.pyindex 31412a0f4..7c937a036 100644--- a/scrapy/core/downloader/handlers/http11.py+++ b/scrapy/core/downloader/handlers/http11.py@@ -6,7 +6,7 @@ from io import BytesIOfrom time import timefrom six.moves.urllib.parse import urldefrag-from zope.interface import implements+from zope.interface import implementerfrom twisted.internet import defer, reactor, protocolfrom twisted.web.http_headers import Headers as TxHeadersfrom twisted.web.iweb import IBodyProducer, UNKNOWN_LENGTH@@ -265,8 +265,8 @@ class ScrapyAgent(object):return respcls(url=url, status=status, headers=headers, body=body, flags=flags)+@implementer(IBodyProducer)class _RequestBodyProducer(object):- implements(IBodyProducer)def __init__(self, body):self.body = bodydiff --git a/tests/test_downloader_handlers.py b/tests/test_downloader_handlers.pyindex d2a349b40..5f1703c5c 100644--- a/tests/test_downloader_handlers.py+++ b/tests/test_downloader_handlers.py@@ -10,9 +10,7 @@ from twisted.web import server, static, util, resourcefrom twisted.web.test.test_webclient import ForeverTakingResource, \NoLengthResource, HostHeaderResource, \PayloadResource, BrokenDownloadResource-from twisted.protocols.ftp import FTPRealm, FTPFactoryfrom twisted.cred import portal, checkers, credentials-from twisted.protocols.ftp import FTPClient, ConnectionLostfrom w3lib.url import path_to_file_urifrom scrapy import twisted_version@@ -22,7 +20,6 @@ from scrapy.core.downloader.handlers.http import HTTPDownloadHandler, HttpDownlofrom scrapy.core.downloader.handlers.http10 import HTTP10DownloadHandlerfrom scrapy.core.downloader.handlers.http11 import HTTP11DownloadHandlerfrom scrapy.core.downloader.handlers.s3 import S3DownloadHandler-from scrapy.core.downloader.handlers.ftp import FTPDownloadHandlerfrom scrapy.spiders import Spiderfrom scrapy.http import Request@@ -520,6 +517,9 @@ class FTPTestCase(unittest.TestCase):skip = "Twisted pre 10.2.0 doesn't allow to set home path other than /home"def setUp(self):+ from twisted.protocols.ftp import FTPRealm, FTPFactory+ from scrapy.core.downloader.handlers.ftp import FTPDownloadHandler+# setup dirs and test fileself.directory = self.mktemp()os.mkdir(self.directory)@@ -601,6 +601,8 @@ class FTPTestCase(unittest.TestCase):return self._add_test_callbacks(d, _test)def test_invalid_credentials(self):+ from twisted.protocols.ftp import ConnectionLost+request = Request(url="ftp://127.0.0.1:%s/file.txt" % self.portNum,meta={"ftp_user": self.username, "ftp_password": 'invalid'})d = self.download_handler.download_request(request, None)