[1.10.x] Fixed #26945 -- Ensured that i18n_patterns returns a list

Backport of 971120778a from master
This commit is contained in:
Alex Hill 2016-07-24 22:00:39 +08:00 committed by Markus Holtermann
parent b4fa102503
commit 4e8ccb3274
No known key found for this signature in database
GPG Key ID: AFE79D68D41C7E39
2 changed files with 7 additions and 1 deletions

View File

@ -12,7 +12,7 @@ def i18n_patterns(*urls, **kwargs):
URLconf.
"""
if not settings.USE_I18N:
return urls
return list(urls)
prefix_default_language = kwargs.pop('prefix_default_language', True)
assert not kwargs, 'Unexpected kwargs for i18n_patterns(): %s' % kwargs
return [LocaleRegexURLResolver(list(urls), prefix_default_language=prefix_default_language)]

View File

@ -1512,6 +1512,12 @@ class MiscTests(SimpleTestCase):
with self.settings(LANGUAGES=[('en', 'English')]):
self.assertNotEqual('pt-br', g(r))
def test_i18n_patterns_returns_list(self):
with override_settings(USE_I18N=False):
self.assertIsInstance(i18n_patterns([]), list)
with override_settings(USE_I18N=True):
self.assertIsInstance(i18n_patterns([]), list)
class ResolutionOrderI18NTests(SimpleTestCase):