1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #31380 -- Added deployment system check for DJANGO_ALLOW_ASYNC_UNSAFE environment variable.

This commit is contained in:
hashlash
2020-03-21 03:20:48 +07:00
committed by Mariusz Felisiak
parent e9b014fbc5
commit 4a6f2b63d7
5 changed files with 49 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
import os
from unittest import mock
from django.core.checks.async_checks import E001, check_async_unsafe
from django.test import SimpleTestCase
class AsyncCheckTests(SimpleTestCase):
@mock.patch.dict(os.environ, {'DJANGO_ALLOW_ASYNC_UNSAFE': ''})
def test_no_allowed_async_unsafe(self):
self.assertEqual(check_async_unsafe(None), [])
@mock.patch.dict(os.environ, {'DJANGO_ALLOW_ASYNC_UNSAFE': 'true'})
def test_allowed_async_unsafe_set(self):
self.assertEqual(check_async_unsafe(None), [E001])