Loading django/conf/__init__.py +4 −3 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ class LazySettings(LazyObject): The user can manually configure settings prior to using them. Otherwise, Django uses the settings module pointed to by DJANGO_SETTINGS_MODULE. """ def _setup(self, name): def _setup(self, name=None): """ Load the settings module pointed to by the environment variable. This is used the first time we need any settings at all, if the user has not Loading @@ -36,11 +36,12 @@ class LazySettings(LazyObject): if not settings_module: # If it's set but is an empty string. raise KeyError except KeyError: desc = ("setting %s" % name) if name else "settings" raise ImproperlyConfigured( "Requested setting %s, but settings are not configured. " "Requested %s, but settings are not configured. " "You must either define the environment variable %s " "or call settings.configure() before accessing settings." % (name, ENVIRONMENT_VARIABLE)) % (desc, ENVIRONMENT_VARIABLE)) self._wrapped = Settings(settings_module) self._configure_logging() Loading tests/regressiontests/admin_scripts/tests.py +12 −0 Original line number Diff line number Diff line Loading @@ -1603,3 +1603,15 @@ class StartProject(LiveServerTestCase, AdminScriptTestCase): with codecs.open(path, 'r', 'utf-8') as f: self.assertEqual(f.read(), 'Some non-ASCII text for testing ticket #18091:\nüäö €\n') class DiffSettings(AdminScriptTestCase): """Tests for diffsettings management command.""" def test_basic(self): "Runs without error and emits settings diff." self.write_settings('settings_to_diff.py', sdict={'FOO': '"bar"'}) args = ['diffsettings', '--settings=settings_to_diff'] out, err = self.run_manage(args) self.remove_settings('settings_to_diff.py') self.assertNoOutput(err) self.assertOutput(out, "FOO = 'bar' ###") Loading
django/conf/__init__.py +4 −3 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ class LazySettings(LazyObject): The user can manually configure settings prior to using them. Otherwise, Django uses the settings module pointed to by DJANGO_SETTINGS_MODULE. """ def _setup(self, name): def _setup(self, name=None): """ Load the settings module pointed to by the environment variable. This is used the first time we need any settings at all, if the user has not Loading @@ -36,11 +36,12 @@ class LazySettings(LazyObject): if not settings_module: # If it's set but is an empty string. raise KeyError except KeyError: desc = ("setting %s" % name) if name else "settings" raise ImproperlyConfigured( "Requested setting %s, but settings are not configured. " "Requested %s, but settings are not configured. " "You must either define the environment variable %s " "or call settings.configure() before accessing settings." % (name, ENVIRONMENT_VARIABLE)) % (desc, ENVIRONMENT_VARIABLE)) self._wrapped = Settings(settings_module) self._configure_logging() Loading
tests/regressiontests/admin_scripts/tests.py +12 −0 Original line number Diff line number Diff line Loading @@ -1603,3 +1603,15 @@ class StartProject(LiveServerTestCase, AdminScriptTestCase): with codecs.open(path, 'r', 'utf-8') as f: self.assertEqual(f.read(), 'Some non-ASCII text for testing ticket #18091:\nüäö €\n') class DiffSettings(AdminScriptTestCase): """Tests for diffsettings management command.""" def test_basic(self): "Runs without error and emits settings diff." self.write_settings('settings_to_diff.py', sdict={'FOO': '"bar"'}) args = ['diffsettings', '--settings=settings_to_diff'] out, err = self.run_manage(args) self.remove_settings('settings_to_diff.py') self.assertNoOutput(err) self.assertOutput(out, "FOO = 'bar' ###")