1
0
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:
Andrew Godwin
2020-03-05 14:26:33 +01:00
committed by Mariusz Felisiak
parent 2f53d324de
commit 17009e9105
3 changed files with 8 additions and 11 deletions

View File

@@ -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()