mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
[2.1.x] Reverted "Fixed #29324 -- Made Settings raise ImproperlyConfigured if SECRET_KEY is accessed and not set."
This reverts commitb3cffde555due to a regression and performance concerns. Backport of5cc81cd9ebfrom master
This commit is contained in:
@@ -2213,11 +2213,7 @@ class DiffSettings(AdminScriptTestCase):
|
||||
out, err = self.run_manage(args)
|
||||
self.assertNoOutput(err)
|
||||
self.assertOutput(out, "+ FOO = 'bar'")
|
||||
self.assertOutput(out, "- INSTALLED_APPS = []")
|
||||
self.assertOutput(
|
||||
out,
|
||||
"+ INSTALLED_APPS = ['django.contrib.auth', 'django.contrib.contenttypes', 'admin_scripts']"
|
||||
)
|
||||
self.assertOutput(out, "- SECRET_KEY = ''")
|
||||
self.assertOutput(out, "+ SECRET_KEY = 'django_tests_secret_key'")
|
||||
self.assertNotInOutput(out, " APPEND_SLASH = True")
|
||||
|
||||
@@ -2233,12 +2229,7 @@ class DiffSettings(AdminScriptTestCase):
|
||||
self.assertNoOutput(err)
|
||||
self.assertOutput(out, " APPEND_SLASH = True")
|
||||
self.assertOutput(out, "+ FOO = 'bar'")
|
||||
self.assertOutput(out, "- INSTALLED_APPS = []")
|
||||
self.assertOutput(
|
||||
out,
|
||||
"+ INSTALLED_APPS = ['django.contrib.auth', 'django.contrib.contenttypes', 'admin_scripts']"
|
||||
)
|
||||
self.assertOutput(out, "+ SECRET_KEY = 'django_tests_secret_key'")
|
||||
self.assertOutput(out, "- SECRET_KEY = ''")
|
||||
|
||||
|
||||
class Dumpdata(AdminScriptTestCase):
|
||||
|
||||
@@ -291,20 +291,8 @@ class SettingsTests(SimpleTestCase):
|
||||
def test_no_secret_key(self):
|
||||
settings_module = ModuleType('fake_settings_module')
|
||||
sys.modules['fake_settings_module'] = settings_module
|
||||
msg = 'The SECRET_KEY setting must be set.'
|
||||
msg = 'The SECRET_KEY setting must not be empty.'
|
||||
try:
|
||||
settings = Settings('fake_settings_module')
|
||||
with self.assertRaisesMessage(ImproperlyConfigured, msg):
|
||||
settings.SECRET_KEY
|
||||
finally:
|
||||
del sys.modules['fake_settings_module']
|
||||
|
||||
def test_secret_key_empty_string(self):
|
||||
settings_module = ModuleType('fake_settings_module')
|
||||
settings_module.SECRET_KEY = ''
|
||||
sys.modules['fake_settings_module'] = settings_module
|
||||
try:
|
||||
msg = 'The SECRET_KEY setting must not be empty.'
|
||||
with self.assertRaisesMessage(ImproperlyConfigured, msg):
|
||||
Settings('fake_settings_module')
|
||||
finally:
|
||||
|
||||
Reference in New Issue
Block a user