diff --git a/tests/test_downloader_handlers_http2.py b/tests/test_downloader_handlers_http2.py index 174bf841e..723271123 100644 --- a/tests/test_downloader_handlers_http2.py +++ b/tests/test_downloader_handlers_http2.py @@ -23,6 +23,9 @@ pytestmark = pytest.mark.skipif( not H2_ENABLED, reason="HTTP/2 support in Twisted is not enabled" ) +# pylint: disable-next=ungrouped-imports +from scrapy.core.downloader.handlers.http2 import H2DownloadHandler # noqa: E402 + class BaseTestClasses: # A hack to prevent tests from the imported classes to run here too. @@ -50,19 +53,13 @@ class BaseTestClasses: ) -def _get_dh() -> type[DownloadHandlerProtocol]: - from scrapy.core.downloader.handlers.http2 import H2DownloadHandler - - return H2DownloadHandler - - class Https2TestCase(BaseTestClasses.Https11TestCase): scheme = "https" HTTP2_DATALOSS_SKIP_REASON = "Content-Length mismatch raises InvalidBodyLengthError" @property def download_handler_cls(self) -> type[DownloadHandlerProtocol]: - return _get_dh() + return H2DownloadHandler def test_protocol(self): request = Request(self.getURL("host"), method="GET") @@ -183,25 +180,25 @@ class Https2TestCase(BaseTestClasses.Https11TestCase): class Https2WrongHostnameTestCase(BaseTestClasses.Https11WrongHostnameTestCase): @property def download_handler_cls(self) -> type[DownloadHandlerProtocol]: - return _get_dh() + return H2DownloadHandler class Https2InvalidDNSId(BaseTestClasses.Https11InvalidDNSId): @property def download_handler_cls(self) -> type[DownloadHandlerProtocol]: - return _get_dh() + return H2DownloadHandler class Https2InvalidDNSPattern(BaseTestClasses.Https11InvalidDNSPattern): @property def download_handler_cls(self) -> type[DownloadHandlerProtocol]: - return _get_dh() + return H2DownloadHandler class Https2CustomCiphers(BaseTestClasses.Https11CustomCiphers): @property def download_handler_cls(self) -> type[DownloadHandlerProtocol]: - return _get_dh() + return H2DownloadHandler class Http2MockServerTestCase(BaseTestClasses.Http11MockServerTestCase): @@ -227,7 +224,7 @@ class Https2ProxyTestCase(BaseTestClasses.Http11ProxyTestCase): @property def download_handler_cls(self) -> type[DownloadHandlerProtocol]: - return _get_dh() + return H2DownloadHandler def setUp(self): site = server.Site(UriResource(), timeout=None)