From 8929afb8ec4bc2bfb95b66c05fc3ab39e3748d91 Mon Sep 17 00:00:00 2001 From: Baptiste Mispelon Date: Thu, 21 Nov 2019 20:34:58 +0100 Subject: Fixed #9762 -- Made DateFormat.r() locale-independent. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thanks to Antonio Melé for the original report all those years ago and to all the contributors who helped along the way. --- tests/utils_tests/test_dateformat.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'tests/utils_tests') diff --git a/tests/utils_tests/test_dateformat.py b/tests/utils_tests/test_dateformat.py index a77395cbf3..d050ac4352 100644 --- a/tests/utils_tests/test_dateformat.py +++ b/tests/utils_tests/test_dateformat.py @@ -131,7 +131,7 @@ class DateFormatTests(SimpleTestCase): if TZ_SUPPORT: self.assertEqual(dateformat.format(my_birthday, 'O'), '+0100') - self.assertEqual(dateformat.format(my_birthday, 'r'), 'Sun, 8 Jul 1979 22:00:00 +0100') + self.assertEqual(dateformat.format(my_birthday, 'r'), 'Sun, 08 Jul 1979 22:00:00 +0100') self.assertEqual(dateformat.format(my_birthday, 'T'), 'CET') self.assertEqual(dateformat.format(my_birthday, 'e'), '') self.assertEqual(dateformat.format(aware_dt, 'e'), '-0330') @@ -156,3 +156,12 @@ class DateFormatTests(SimpleTestCase): ) with self.assertRaisesMessage(TypeError, msg): dateformat.format(my_birthday, specifier) + + def test_r_format_with_non_en_locale(self): + # Changing the locale doesn't change the "r" format. + dt = datetime(1979, 7, 8, 22, 00) + with translation.override('fr'): + self.assertEqual( + dateformat.format(dt, 'r'), + 'Sun, 08 Jul 1979 22:00:00 +0100', + ) -- cgit v1.3