summaryrefslogtreecommitdiff
path: root/tests/i18n/patterns/tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/i18n/patterns/tests.py')
-rw-r--r--tests/i18n/patterns/tests.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/tests/i18n/patterns/tests.py b/tests/i18n/patterns/tests.py
index db04e9a1a4..43d95ff668 100644
--- a/tests/i18n/patterns/tests.py
+++ b/tests/i18n/patterns/tests.py
@@ -8,7 +8,7 @@ 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.urls import clear_url_caches, resolve, reverse, translate_url
from django.utils import translation
@@ -198,6 +198,23 @@ class URLTranslationTests(URLTestCaseBase):
self.assertEqual(translate_url("/nl/gebruikers/", "en"), "/en/users/")
self.assertEqual(translation.get_language(), "nl")
+ def test_reverse_translated_with_captured_kwargs(self):
+ with translation.override("en"):
+ match = resolve("/translated/apo/")
+ # Links to the same page in other languages.
+ tests = [
+ ("nl", "/vertaald/apo/"),
+ ("pt-br", "/traduzidos/apo/"),
+ ]
+ for lang, expected_link in tests:
+ with translation.override(lang):
+ self.assertEqual(
+ reverse(
+ match.url_name, args=match.args, kwargs=match.captured_kwargs
+ ),
+ expected_link,
+ )
+
class URLNamespaceTests(URLTestCaseBase):
"""