From d83af30195b11e4e1c1444047c9bc6b3427e35f2 Mon Sep 17 00:00:00 2001 From: Rogdham Date: Wed, 17 Apr 2013 09:57:48 +0100 Subject: [PATCH] Add French version for testing utils.strftime Do not use abbreviated locale versions of month/whatever, because it seems that this is not standard (e.g. MacOS abbreviating differently than GNU/Linux). --- pelican/tests/test_utils.py | 41 ++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/pelican/tests/test_utils.py b/pelican/tests/test_utils.py index d2d0293e..e40046bd 100644 --- a/pelican/tests/test_utils.py +++ b/pelican/tests/test_utils.py @@ -208,13 +208,11 @@ class TestUtils(LoggedTestCase): # test the output of utils.strftime in a different locale - # right now, this uses Turkish locale - # why Turkish? because I know Turkish :). And it produces non-ascii output - # Feel free to extend with different locales + # Turkish locale @unittest.skipUnless(locale_available('tr_TR.UTF-8') or locale_available('Turkish'), 'Turkish locale needed') - def test_strftime_locale_dependent(self): + def test_strftime_locale_dependent_turkish(self): # store current locale old_locale = locale.setlocale(locale.LC_TIME) @@ -227,7 +225,6 @@ class TestUtils(LoggedTestCase): # simple self.assertEqual(utils.strftime(d, '%d %B %Y'), '29 Ağustos 2012') - self.assertEqual(utils.strftime(d, '%d %b %Y'), '29 Ağu 2012') self.assertEqual(utils.strftime(d, '%A, %d %B %Y'), 'Çarşamba, 29 Ağustos 2012') @@ -241,3 +238,37 @@ class TestUtils(LoggedTestCase): # restore locale back locale.setlocale(locale.LC_TIME, old_locale) + + + # test the output of utils.strftime in a different locale + # French locale + @unittest.skipUnless(locale_available('fr_FR.UTF-8') or + locale_available('French'), + 'French locale needed') + def test_strftime_locale_dependent_french(self): + # store current locale + old_locale = locale.setlocale(locale.LC_TIME) + + if platform == 'win32': + locale.setlocale(locale.LC_TIME, str('French')) + else: + locale.setlocale(locale.LC_TIME, str('fr_FR.UTF-8')) + + d = datetime.date(2012, 8, 29) + + # simple + self.assertEqual(utils.strftime(d, '%d %B %Y'), '29 août 2012') + + # depending on OS, the first letter is m or M + self.assertTrue(utils.strftime(d, '%A') in ('mercredi', 'Mercredi')) + + # with text + self.assertEqual(utils.strftime(d, 'Écrit le %d %B %Y'), + 'Écrit le 29 août 2012') + + # non-ascii format candidate (someone might pass it... for some reason) + self.assertEqual(utils.strftime(d, '%écrits en %Y'), + '%écrits en 2012') + + # restore locale back + locale.setlocale(locale.LC_TIME, old_locale)