Scrapy, a fast high-level web crawling & scraping framework for Python.
Skip MiddlewareUsingCoro::test_asyncdef on asyncio and old Twisted
Adrián Chaves906626cf0bef
diff --git a/tests/test_downloadermiddleware.py b/tests/test_downloadermiddleware.pyindex 79f24c8a1..55af4c240 100644--- a/tests/test_downloadermiddleware.py+++ b/tests/test_downloadermiddleware.py@@ -1,11 +1,12 @@import asyncio-from unittest import mock+from unittest import mock, SkipTestfrom pytest import markfrom twisted.internet import deferfrom twisted.internet.defer import Deferredfrom twisted.trial.unittest import TestCasefrom twisted.python.failure import Failure+from twisted.python.versions import Versionfrom scrapy.http import Request, Responsefrom scrapy.spiders import Spider@@ -211,10 +212,24 @@ class MiddlewareUsingDeferreds(ManagerTestCase):self.assertFalse(download_func.called)[email protected]('reactor_pytest')class MiddlewareUsingCoro(ManagerTestCase):"""Middlewares using asyncio coroutines should work"""def test_asyncdef(self):+ import twisted+ if (+ self.reactor_pytest == 'asyncio'+ and twisted.version < Version('twisted', 18, 4, 0)+ ):+ raise SkipTest(+ 'Due to https://twistedmatrix.com/trac/ticket/9390, this test '+ 'hangs when using AsyncIO and Twisted versions lower than '+ '18.4.0'+ )++ from twisted.python.versions import Version+resp = Response('http://example.com/index.html')class CoroMiddleware: