diff --git a/django/conf/__init__.py b/django/conf/__init__.py
index d94f6e9..bde2101 100644
a
|
b
|
class Settings(object):
|
108 | 108 | os.environ['TZ'] = self.TIME_ZONE |
109 | 109 | time.tzset() |
110 | 110 | |
| 111 | def __setattr__(self, name, value): |
| 112 | #Protecting people from themselves if they set MEDIA_URL to a value that |
| 113 | #doesn't end in a trailing slash |
| 114 | if name == "MEDIA_URL" and value and value[-1] != '/': |
| 115 | value = "%s/" % value |
| 116 | object.__setattr__(self, name, value) |
| 117 | |
111 | 118 | class UserSettingsHolder(object): |
112 | 119 | """ |
113 | 120 | Holder for user configured settings. |
diff --git a/tests/regressiontests/settings_tests/tests.py b/tests/regressiontests/settings_tests/tests.py
index fa217b1..751db8f 100644
a
|
b
|
class SettingsTests(unittest.TestCase):
|
15 | 15 | |
16 | 16 | def test_settings_delete_wrapped(self): |
17 | 17 | self.assertRaises(TypeError, delattr, settings, '_wrapped') |
| 18 | |
| 19 | def test_settings_media_url_trailing_slash(self): |
| 20 | """ |
| 21 | settings.MEDIA_URL should always end with a slash if it's not blank |
| 22 | """ |
| 23 | settings.MEDIA_URL = '' |
| 24 | self.assertEqual('', settings.MEDIA_URL) |
| 25 | del settings.MEDIA_URL |
| 26 | |
| 27 | settings.MEDIA_URL = '/foo/' |
| 28 | self.assertEqual('/foo/', settings.MEDIA_URL) |
| 29 | del settings.MEDIA_URL |
| 30 | |
| 31 | settings.MEDIA_URL = '/foo' |
| 32 | self.assertEqual('/foo/', settings.MEDIA_URL) |
| 33 | del settings.MEDIA_URL |
| 34 | |
| 35 | settings.MEDIA_URL = 'http://media.foo.com' |
| 36 | self.assertEqual('http://media.foo.com/', settings.MEDIA_URL) |
| 37 | del settings.MEDIA_URL |
| 38 | |
| 39 | settings.MEDIA_URL = 'http://media.foo.com/' |
| 40 | self.assertEqual('http://media.foo.com/', settings.MEDIA_URL) |
| 41 | del settings.MEDIA_URL |
| 42 | |
| 43 | #If someone does something stupid, presume they know what they're doing |
| 44 | settings.MEDIA_URL = 'http://media.foo.com/stupid//' |
| 45 | self.assertEqual('http://media.foo.com/stupid//', settings.MEDIA_URL) |
| 46 | No newline at end of file |