From ddcb9e806275114c91bbed90bc917374ba08a9ae Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Sat, 29 Sep 2018 15:06:11 +0200 Subject: [PATCH] Refs #21408 -- Updated naturaltime translation test. Upcoming German translations will not differ for past and future naturaltime translations. Using Czech language instead. --- tests/humanize_tests/tests.py | 36 ++++++++++++++++++++++++++--------- 1 file 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