summaryrefslogtreecommitdiff
path: root/tests/humanize_tests
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2018-09-29 15:06:11 +0200
committerCarlton Gibson <carlton.gibson@noumenal.es>2018-09-29 15:06:11 +0200
commitddcb9e806275114c91bbed90bc917374ba08a9ae (patch)
treefcf4893e7c436529f8b62a90540b24f0b09081df /tests/humanize_tests
parent8ef8bc0f64c463684268a7c55f3d3da4de066c0d (diff)
downloaddjango-ddcb9e806275114c91bbed90bc917374ba08a9ae.tar.gz
Refs #21408 -- Updated naturaltime translation test.
Upcoming German translations will not differ for past and future naturaltime translations. Using Czech language instead.
Diffstat (limited to 'tests/humanize_tests')
-rw-r--r--tests/humanize_tests/tests.py36
1 files changed, 27 insertions, 9 deletions
diff --git a/tests/humanize_tests/tests.py b/tests/humanize_tests/tests.py
index 2414a55ed7..25cd07bac7 100644
--- a/tests/humanize_tests/tests.py
+++ b/tests/humanize_tests/tests.py
@@ -290,28 +290,46 @@ class HumanizeTests(SimpleTestCase):
finally:
humanize.datetime = orig_humanize_datetime
- def test_dative_inflection_for_timedelta(self):
- """Translation may differ depending on the string it is inserted in."""
+ def test_inflection_for_timedelta(self):
+ """
+ Translation of '%d day'/'%d month'/… may differ depending on the context
+ of the string it is inserted in.
+ """
test_list = [
+ # "%(delta)s ago" translations
now - datetime.timedelta(days=1),
now - datetime.timedelta(days=2),
now - datetime.timedelta(days=30),
now - datetime.timedelta(days=60),
now - datetime.timedelta(days=500),
now - datetime.timedelta(days=865),
+ # "%(delta)s from now" translations
+ now + datetime.timedelta(days=1),
+ now + datetime.timedelta(days=2),
+ now + datetime.timedelta(days=30),
+ now + datetime.timedelta(days=60),
+ now + datetime.timedelta(days=500),
+ now + datetime.timedelta(days=865),
]
result_list = [
- 'vor 1\xa0Tag',
- 'vor 2\xa0Tagen',
- 'vor 1\xa0Monat',
- 'vor 2\xa0Monaten',
- 'vor 1\xa0Jahr, 4\xa0Monaten',
- 'vor 2\xa0Jahren, 4\xa0Monaten',
+ 'před 1\xa0dnem',
+ 'před 2\xa0dny',
+ 'před 1\xa0měsícem',
+ 'před 2\xa0měsíci',
+ 'před 1\xa0rokem, 4\xa0měsíci',
+ 'před 2\xa0lety, 4\xa0měsíci',
+ 'za 1\xa0den',
+ 'za 2\xa0dny',
+ 'za 1\xa0měsíc',
+ 'za 2\xa0měsíce',
+ 'za 1\xa0rok, 4\xa0měsíce',
+ 'za 2\xa0roky, 4\xa0měsíce',
]
orig_humanize_datetime, humanize.datetime = humanize.datetime, MockDateTime
try:
- with translation.override('de'), self.settings(USE_L10N=True):
+ # Choose a language with different naturaltime-past/naturaltime-future translations
+ with translation.override('cs'), self.settings(USE_L10N=True):
self.humanize_tester(test_list, result_list, 'naturaltime')
finally:
humanize.datetime = orig_humanize_datetime