summaryrefslogtreecommitdiff
path: root/tests/settings_tests
diff options
context:
space:
mode:
authorKeryn Knight <keryn@kerynknight.com>2015-07-28 15:37:41 +0100
committerTim Graham <timograham@gmail.com>2015-08-31 16:08:30 -0400
commit9c40f01a66bd15457e10a0bbf28c803968b5dabb (patch)
tree419279aeef4b66f7ae1c471889e294d3f2b4817e /tests/settings_tests
parent123984ff66c788a7ea36256c152b79dd06e9ef31 (diff)
downloaddjango-9c40f01a66bd15457e10a0bbf28c803968b5dabb.tar.gz
Refs #24121 -- Added repr() to LazySettings, Settings, and UserSettingsHolder.
Diffstat (limited to 'tests/settings_tests')
-rw-r--r--tests/settings_tests/tests.py27
1 files changed, 26 insertions, 1 deletions
diff --git a/tests/settings_tests/tests.py b/tests/settings_tests/tests.py
index be1cb426d8..ed5ae785ec 100644
--- a/tests/settings_tests/tests.py
+++ b/tests/settings_tests/tests.py
@@ -4,7 +4,7 @@ import unittest
import warnings
from types import ModuleType
-from django.conf import LazySettings, Settings, settings
+from django.conf import ENVIRONMENT_VARIABLE, LazySettings, Settings, settings
from django.core.exceptions import ImproperlyConfigured
from django.http import HttpRequest
from django.test import (
@@ -442,6 +442,31 @@ class IsOverriddenTest(SimpleTestCase):
with override_settings(ALLOWED_HOSTS=[]):
self.assertTrue(settings.is_overridden('ALLOWED_HOSTS'))
+ def test_unevaluated_lazysettings_repr(self):
+ lazy_settings = LazySettings()
+ expected = '<LazySettings [Unevaluated]>'
+ self.assertEqual(repr(lazy_settings), expected)
+
+ def test_evaluated_lazysettings_repr(self):
+ lazy_settings = LazySettings()
+ module = os.environ.get(ENVIRONMENT_VARIABLE)
+ expected = '<LazySettings "%s">' % module
+ # Force evaluation of the lazy object.
+ lazy_settings.APPEND_SLASH
+ self.assertEqual(repr(lazy_settings), expected)
+
+ def test_usersettingsholder_repr(self):
+ lazy_settings = LazySettings()
+ lazy_settings.configure(APPEND_SLASH=False)
+ expected = '<UserSettingsHolder>'
+ self.assertEqual(repr(lazy_settings._wrapped), expected)
+
+ def test_settings_repr(self):
+ module = os.environ.get(ENVIRONMENT_VARIABLE)
+ lazy_settings = Settings(module)
+ expected = '<Settings "%s">' % module
+ self.assertEqual(repr(lazy_settings), expected)
+
class TestListSettings(unittest.TestCase):
"""