summaryrefslogtreecommitdiff
path: root/django/test
diff options
context:
space:
mode:
Diffstat (limited to 'django/test')
-rw-r--r--django/test/testcases.py5
-rw-r--r--django/test/utils.py5
2 files changed, 5 insertions, 5 deletions
diff --git a/django/test/testcases.py b/django/test/testcases.py
index c78c2300a7..090a31e7c4 100644
--- a/django/test/testcases.py
+++ b/django/test/testcases.py
@@ -1,4 +1,3 @@
-import asyncio
import difflib
import inspect
import json
@@ -26,7 +25,7 @@ from urllib.parse import (
)
from urllib.request import url2pathname
-from asgiref.sync import async_to_sync
+from asgiref.sync import async_to_sync, iscoroutinefunction
from django.apps import apps
from django.conf import settings
@@ -401,7 +400,7 @@ class SimpleTestCase(unittest.TestCase):
)
# Convert async test methods.
- if asyncio.iscoroutinefunction(testMethod):
+ if iscoroutinefunction(testMethod):
setattr(self, self._testMethodName, async_to_sync(testMethod))
if not skipped:
diff --git a/django/test/utils.py b/django/test/utils.py
index 2b2b92c593..5e5649b0ac 100644
--- a/django/test/utils.py
+++ b/django/test/utils.py
@@ -1,4 +1,3 @@
-import asyncio
import collections
import logging
import os
@@ -14,6 +13,8 @@ from types import SimpleNamespace
from unittest import TestCase, skipIf, skipUnless
from xml.dom.minidom import Node, parseString
+from asgiref.sync import iscoroutinefunction
+
from django.apps import apps
from django.apps.registry import Apps
from django.conf import UserSettingsHolder, settings
@@ -440,7 +441,7 @@ class TestContextDecorator:
raise TypeError("Can only decorate subclasses of unittest.TestCase")
def decorate_callable(self, func):
- if asyncio.iscoroutinefunction(func):
+ if iscoroutinefunction(func):
# If the inner function is an async function, we must execute async
# as well so that the `with` statement executes at the right time.
@wraps(func)