mirror of
https://github.com/django/django.git
synced 2025-10-26 07:06:08 +00:00
Fixed #26295 -- Allowed using i18n_patterns() in any root URLconf.
Thanks Tim for the review.
This commit is contained in:
@@ -7,6 +7,7 @@ from django.http import HttpResponsePermanentRedirect
|
||||
from django.middleware.locale import LocaleMiddleware
|
||||
from django.template import Context, Template
|
||||
from django.test import SimpleTestCase, override_settings
|
||||
from django.test.client import RequestFactory
|
||||
from django.test.utils import override_script_prefix
|
||||
from django.urls import clear_url_caches, reverse, translate_url
|
||||
from django.utils import translation
|
||||
@@ -92,6 +93,18 @@ class URLDisabledTests(URLTestCaseBase):
|
||||
self.assertEqual(reverse('prefixed'), '/prefixed/')
|
||||
|
||||
|
||||
class RequestURLConfTests(SimpleTestCase):
|
||||
|
||||
@override_settings(ROOT_URLCONF='i18n.patterns.urls.path_unused')
|
||||
def test_request_urlconf_considered(self):
|
||||
request = RequestFactory().get('/nl/')
|
||||
request.urlconf = 'i18n.patterns.urls.default'
|
||||
middleware = LocaleMiddleware()
|
||||
with translation.override('nl'):
|
||||
middleware.process_request(request)
|
||||
self.assertEqual(request.LANGUAGE_CODE, 'nl')
|
||||
|
||||
|
||||
@override_settings(ROOT_URLCONF='i18n.patterns.urls.path_unused')
|
||||
class PathUnusedTests(URLTestCaseBase):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user