diff options
author | Adam Chainz <me@adamj.eu> | 2016-12-23 15:55:00 +0000 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2016-12-23 10:55:00 -0500 |
commit | 8669cf0e684696971f6b577f5023634cb16f307e (patch) | |
tree | c57f1d5dc8ff02a6721222fb212cc6db223a6572 /tests/settings_tests | |
parent | 8d94d575f821b16a25bfd9fcf739f2ee2febe2be (diff) | |
download | django-8669cf0e684696971f6b577f5023634cb16f307e.tar.gz |
Fixed #27626 -- Moved MEDIA_URL/STATIC_URL validation to a system check.
Diffstat (limited to 'tests/settings_tests')
-rw-r--r-- | tests/settings_tests/tests.py | 78 |
1 files changed, 0 insertions, 78 deletions
diff --git a/tests/settings_tests/tests.py b/tests/settings_tests/tests.py index 8f50a854e4..bf015affc2 100644 --- a/tests/settings_tests/tests.py +++ b/tests/settings_tests/tests.py @@ -310,84 +310,6 @@ class TestComplexSettingOverride(SimpleTestCase): self.assertEqual(str(w[0].message), 'Overriding setting TEST_WARN can lead to unexpected behavior.') -class TrailingSlashURLTests(SimpleTestCase): - """ - Tests for the MEDIA_URL and STATIC_URL settings. - - They must end with a slash to ensure there's a deterministic way to build - paths in templates. - """ - settings_module = settings - - def setUp(self): - self._original_media_url = self.settings_module.MEDIA_URL - self._original_static_url = self.settings_module.STATIC_URL - - def tearDown(self): - self.settings_module.MEDIA_URL = self._original_media_url - self.settings_module.STATIC_URL = self._original_static_url - - def test_blank(self): - """ - The empty string is accepted, even though it doesn't end in a slash. - """ - self.settings_module.MEDIA_URL = '' - self.assertEqual('', self.settings_module.MEDIA_URL) - - self.settings_module.STATIC_URL = '' - self.assertEqual('', self.settings_module.STATIC_URL) - - def test_end_slash(self): - """ - It works if the value ends in a slash. - """ - self.settings_module.MEDIA_URL = '/foo/' - self.assertEqual('/foo/', self.settings_module.MEDIA_URL) - - self.settings_module.MEDIA_URL = 'http://media.foo.com/' - self.assertEqual('http://media.foo.com/', self.settings_module.MEDIA_URL) - - self.settings_module.STATIC_URL = '/foo/' - self.assertEqual('/foo/', self.settings_module.STATIC_URL) - - self.settings_module.STATIC_URL = 'http://static.foo.com/' - self.assertEqual('http://static.foo.com/', self.settings_module.STATIC_URL) - - def test_no_end_slash(self): - """ - An ImproperlyConfigured exception is raised if the value doesn't end - in a slash. - """ - with self.assertRaises(ImproperlyConfigured): - self.settings_module.MEDIA_URL = '/foo' - - with self.assertRaises(ImproperlyConfigured): - self.settings_module.MEDIA_URL = 'http://media.foo.com' - - with self.assertRaises(ImproperlyConfigured): - self.settings_module.STATIC_URL = '/foo' - - with self.assertRaises(ImproperlyConfigured): - self.settings_module.STATIC_URL = 'http://static.foo.com' - - def test_double_slash(self): - """ - If the value ends in more than one slash, presume they know what - they're doing. - """ - self.settings_module.MEDIA_URL = '/wrong//' - self.assertEqual('/wrong//', self.settings_module.MEDIA_URL) - - self.settings_module.MEDIA_URL = 'http://media.foo.com/wrong//' - self.assertEqual('http://media.foo.com/wrong//', self.settings_module.MEDIA_URL) - - self.settings_module.STATIC_URL = '/wrong//' - self.assertEqual('/wrong//', self.settings_module.STATIC_URL) - - self.settings_module.STATIC_URL = 'http://static.foo.com/wrong//' - self.assertEqual('http://static.foo.com/wrong//', self.settings_module.STATIC_URL) - - class SecureProxySslHeaderTest(SimpleTestCase): @override_settings(SECURE_PROXY_SSL_HEADER=None) |