Ticket #28556: 28556-test.diff

File 28556-test.diff, 1.2 KB (added by Tim Graham, 5 years ago)
  • new file tests/i18n/test_28556.py

    diff --git a/tests/i18n/test_28556.py b/tests/i18n/test_28556.py
    new file mode 100644
    index 0000000..e3827ce
    - +  
     1from django.test import SimpleTestCase, override_settings
     2from django.urls import resolve
     3
     4@override_settings(
     5    USE_I18N=True,
     6    LANGUAGES=[
     7        ('en', 'English'),
     8        ('de', 'German'),
     9        ('fr', 'French'),
     10    ],
     11    MIDDLEWARE=[
     12        'django.middleware.locale.LocaleMiddleware',
     13        'django.middleware.common.CommonMiddleware',
     14    ],
     15    ROOT_URLCONF='i18n.urls_unprefixed',
     16    LANGUAGE_CODE='en',
     17)
     18class UnprefixedDefaultLanguageTests2(SimpleTestCase):
     19
     20    def test_resolve(self):
     21        self.assertEqual(resolve('/').view_name, 'i18n.urls_unprefixed.empty_view')
  • new file tests/i18n/urls_unprefixed.py

    diff --git a/tests/i18n/urls_unprefixed.py b/tests/i18n/urls_unprefixed.py
    new file mode 100644
    index 0000000..98228b8
    - +  
     1from django.conf.urls import url
     2from django.conf.urls.i18n import i18n_patterns
     3from django.http import HttpResponse
     4
     5def empty_view(request):
     6    return HttpResponse()
     7
     8urlpatterns = i18n_patterns(
     9    url(r'', empty_view),
     10    prefix_default_language=False,
     11)
Back to Top