mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #30234 -- Disallowed non-upper settings in settings.configure().
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user