Skip to content

Commit 8ea5b35

Browse files
committed
Install async-asgi-testclient for full tests
1 parent 4777fc8 commit 8ea5b35

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

tornado/test/asgi_test.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
from async_asgi_testclient import TestClient # type: ignore
1+
import unittest
2+
3+
try:
4+
import async_asgi_testclient # type: ignore
5+
except ImportError:
6+
async_asgi_testclient = None
27

38
from tornado.asgi import ASGIAdapter
49
from tornado.web import Application, RequestHandler
@@ -33,13 +38,16 @@ def post(self, path_var):
3338
return self.make_response(path_var)
3439

3540

41+
@unittest.skipIf(
42+
async_asgi_testclient is None, "async_asgi_testclient module not present"
43+
)
3644
class AsyncASGITestCase(AsyncTestCase):
3745
def setUp(self) -> None:
3846
super().setUp()
3947
self.asgi_app = ASGIAdapter(
4048
Application([(r"/", BasicHandler), (r"/inspect(/.*)", InspectHandler)])
4149
)
42-
self.client = TestClient(self.asgi_app)
50+
self.client = async_asgi_testclient.TestClient(self.asgi_app)
4351

4452
@gen_test(timeout=10)
4553
async def test_basic_request(self):

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ deps =
5050
# And since CaresResolver is deprecated, I do not expect to fix it, so just
5151
# pin the previous version. (This should really be in requirements.{in,txt} instead)
5252
full: pycares<5
53+
full: async-asgi-testclient
5354
docs: -r{toxinidir}/requirements.txt
5455
lint: -r{toxinidir}/requirements.txt
5556

0 commit comments

Comments
 (0)