mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Refs #31224 -- Added autoconversion of test async methods.
This commit is contained in:
committed by
Mariusz Felisiak
parent
2f53d324de
commit
17009e9105
@@ -1,3 +1,4 @@
|
||||
import asyncio
|
||||
import difflib
|
||||
import json
|
||||
import posixpath
|
||||
@@ -16,6 +17,8 @@ from urllib.parse import (
|
||||
)
|
||||
from urllib.request import url2pathname
|
||||
|
||||
from asgiref.sync import async_to_sync
|
||||
|
||||
from django.apps import apps
|
||||
from django.conf import settings
|
||||
from django.core import mail
|
||||
@@ -257,6 +260,10 @@ class SimpleTestCase(unittest.TestCase):
|
||||
getattr(testMethod, "__unittest_skip__", False)
|
||||
)
|
||||
|
||||
# Convert async test methods.
|
||||
if asyncio.iscoroutinefunction(testMethod):
|
||||
setattr(self, self._testMethodName, async_to_sync(testMethod))
|
||||
|
||||
if not skipped:
|
||||
try:
|
||||
self._pre_setup()
|
||||
|
||||
Reference in New Issue
Block a user