summaryrefslogtreecommitdiff
path: root/tests/test_utils/tests.py
diff options
context:
space:
mode:
authorChris Lamb <chris@chris-lamb.co.uk>2017-02-25 02:58:56 +0800
committerTim Graham <timograham@gmail.com>2017-02-24 14:06:42 -0500
commit5a85f2ca5fc3c4292cd1b147198d75d0f141fd71 (patch)
tree9e2fa2afd687e6ad61b606309c22aab3b58171e0 /tests/test_utils/tests.py
parent53f5dc10cdc0c1fbeb48b2d98fbdd26c1996ec59 (diff)
[1.11.x] Fixed #27873 -- Fixed crash in setup_test_environment() if ALLOWED_HOSTS is a tuple.
Regression in 17e661641ddaf8266e7430d83cfb2039abc55df7 Backport of 339d526d55baffea3bd3cecd0e07ddf644028e8c from master
Diffstat (limited to 'tests/test_utils/tests.py')
-rw-r--r--tests/test_utils/tests.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/test_utils/tests.py b/tests/test_utils/tests.py
index 54b83f524b..f118ec9565 100644
--- a/tests/test_utils/tests.py
+++ b/tests/test_utils/tests.py
@@ -5,6 +5,7 @@ import sys
import unittest
import warnings
+from django.conf import settings
from django.conf.urls import url
from django.contrib.staticfiles.finders import get_finder, get_finders
from django.contrib.staticfiles.storage import staticfiles_storage
@@ -14,7 +15,7 @@ from django.forms import EmailField, IntegerField
from django.http import HttpResponse
from django.template.loader import render_to_string
from django.test import (
- SimpleTestCase, TestCase, ignore_warnings, skipIfDBFeature,
+ SimpleTestCase, TestCase, ignore_warnings, mock, skipIfDBFeature,
skipUnlessDBFeature,
)
from django.test.html import HTMLParseError, parse_html
@@ -885,6 +886,15 @@ class SetupTestEnvironmentTests(SimpleTestCase):
with self.assertRaisesMessage(RuntimeError, "setup_test_environment() was already called"):
setup_test_environment()
+ def test_allowed_hosts(self):
+ for type_ in (list, tuple):
+ allowed_hosts = type_('*')
+ with mock.patch('django.test.utils._TestState') as x:
+ del x.saved_data
+ with self.settings(ALLOWED_HOSTS=allowed_hosts):
+ setup_test_environment()
+ self.assertEqual(settings.ALLOWED_HOSTS, ['*', 'testserver'])
+
class OverrideSettingsTests(SimpleTestCase):