Skip to content

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.py
index 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, SkipTest
from pytest import mark
from twisted.internet import defer
from twisted.internet.defer import Deferred
from twisted.trial.unittest import TestCase
from twisted.python.failure import Failure
+from twisted.python.versions import Version
from scrapy.http import Request, Response
from 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: