diff options
| author | Carlton Gibson <carlton.gibson@noumenal.es> | 2022-12-20 11:10:48 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-20 11:10:48 +0100 |
| commit | 32d70b2f55b1f74736fd11bc8efce890ad5fa2f0 (patch) | |
| tree | d88822bb2391e7cf4fdbda59b9f222839aeb7e93 /django/test | |
| parent | a09d39f28609c707a62dbbbdc4e55489fae1631f (diff) | |
Refs #34118 -- Adopted asgiref coroutine detection shims.
Thanks to Mariusz Felisiak for review.
Diffstat (limited to 'django/test')
| -rw-r--r-- | django/test/testcases.py | 5 | ||||
| -rw-r--r-- | django/test/utils.py | 5 |
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) |
