Fixed #30234 -- Disallowed non-upper settings in settings.configure().

This commit is contained in:
orlnub123 2019-03-03 03:23:18 +03:00 committed by Tim Graham
parent 9681e968eb
commit 163236ea0e
2 changed files with 15 additions and 2 deletions

View file

@ -1,7 +1,7 @@
import os
import sys
import unittest
from types import ModuleType
from types import ModuleType, SimpleNamespace
from unittest import mock
from django.conf import ENVIRONMENT_VARIABLE, LazySettings, Settings, settings
@ -318,6 +318,17 @@ class SettingsTests(SimpleTestCase):
with self.assertRaisesMessage(RuntimeError, 'Settings already configured.'):
settings.configure()
def test_nonupper_settings_prohibited_in_configure(self):
s = LazySettings()
with self.assertRaisesMessage(TypeError, "Setting 'foo' must be uppercase."):
s.configure(foo='bar')
def test_nonupper_settings_ignored_in_default_settings(self):
s = LazySettings()
s.configure(SimpleNamespace(foo='bar'))
with self.assertRaises(AttributeError):
getattr(s, 'foo')
@requires_tz_support
@mock.patch('django.conf.global_settings.TIME_ZONE', 'test')
def test_incorrect_timezone(self):