Loading django/conf/__init__.py +1 −2 Original line number Diff line number Diff line Loading @@ -69,8 +69,7 @@ class BaseSettings(object): """ def __setattr__(self, name, value): if name in ("MEDIA_URL", "STATIC_URL") and value and not value.endswith('/'): warnings.warn("If set, %s must end with a slash" % name, DeprecationWarning) raise ImproperlyConfigured("If set, %s must end with a slash" % name) elif name == "ADMIN_MEDIA_PREFIX": warnings.warn("The ADMIN_MEDIA_PREFIX setting has been removed; " "use STATIC_URL instead.", DeprecationWarning) Loading tests/regressiontests/settings_tests/tests.py +12 −7 Original line number Diff line number Diff line import os from django.conf import settings, global_settings from django.core.exceptions import ImproperlyConfigured from django.http import HttpRequest from django.test import TransactionTestCase, TestCase, signals from django.test.utils import override_settings Loading Loading @@ -185,22 +186,26 @@ class TrailingSlashURLTests(TestCase): def test_no_end_slash(self): """ MEDIA_URL raises an DeprecationWarning error if it doesn't end in a slash. MEDIA_URL and STATIC_URL raise an ImproperlyConfigured exception if they doesn't end in a slash. """ import warnings warnings.filterwarnings('error', 'If set, MEDIA_URL must end with a slash', DeprecationWarning) def setattr_settings(settings_module, attr, value): setattr(settings_module, attr, value) self.assertRaises(DeprecationWarning, setattr_settings, self.assertRaises(ImproperlyConfigured, setattr_settings, self.settings_module, 'MEDIA_URL', '/foo') self.assertRaises(DeprecationWarning, setattr_settings, self.assertRaises(ImproperlyConfigured, setattr_settings, self.settings_module, 'MEDIA_URL', 'http://media.foo.com') self.assertRaises(ImproperlyConfigured, setattr_settings, self.settings_module, 'STATIC_URL', '/foo') self.assertRaises(ImproperlyConfigured, setattr_settings, self.settings_module, 'STATIC_URL', 'http://static.foo.com') def test_double_slash(self): """ If a MEDIA_URL ends in more than one slash, presume they know what Loading Loading
django/conf/__init__.py +1 −2 Original line number Diff line number Diff line Loading @@ -69,8 +69,7 @@ class BaseSettings(object): """ def __setattr__(self, name, value): if name in ("MEDIA_URL", "STATIC_URL") and value and not value.endswith('/'): warnings.warn("If set, %s must end with a slash" % name, DeprecationWarning) raise ImproperlyConfigured("If set, %s must end with a slash" % name) elif name == "ADMIN_MEDIA_PREFIX": warnings.warn("The ADMIN_MEDIA_PREFIX setting has been removed; " "use STATIC_URL instead.", DeprecationWarning) Loading
tests/regressiontests/settings_tests/tests.py +12 −7 Original line number Diff line number Diff line import os from django.conf import settings, global_settings from django.core.exceptions import ImproperlyConfigured from django.http import HttpRequest from django.test import TransactionTestCase, TestCase, signals from django.test.utils import override_settings Loading Loading @@ -185,22 +186,26 @@ class TrailingSlashURLTests(TestCase): def test_no_end_slash(self): """ MEDIA_URL raises an DeprecationWarning error if it doesn't end in a slash. MEDIA_URL and STATIC_URL raise an ImproperlyConfigured exception if they doesn't end in a slash. """ import warnings warnings.filterwarnings('error', 'If set, MEDIA_URL must end with a slash', DeprecationWarning) def setattr_settings(settings_module, attr, value): setattr(settings_module, attr, value) self.assertRaises(DeprecationWarning, setattr_settings, self.assertRaises(ImproperlyConfigured, setattr_settings, self.settings_module, 'MEDIA_URL', '/foo') self.assertRaises(DeprecationWarning, setattr_settings, self.assertRaises(ImproperlyConfigured, setattr_settings, self.settings_module, 'MEDIA_URL', 'http://media.foo.com') self.assertRaises(ImproperlyConfigured, setattr_settings, self.settings_module, 'STATIC_URL', '/foo') self.assertRaises(ImproperlyConfigured, setattr_settings, self.settings_module, 'STATIC_URL', 'http://static.foo.com') def test_double_slash(self): """ If a MEDIA_URL ends in more than one slash, presume they know what Loading