diff --git a/openerp/tests/test_misc.py b/openerp/tests/test_misc.py index 2f2e99c18d2..8ee7bffc0d0 100644 --- a/openerp/tests/test_misc.py +++ b/openerp/tests/test_misc.py @@ -41,14 +41,29 @@ class test_countingstream(unittest2.TestCase): self.assertEqual(s.index, 0) class TestPosixToBabel(unittest2.TestCase): + """ + Attempts to compare the output of formatting a specific date using various + patterns under strftime and babel. As a result, they need to use the same + locale. + """ def setUp(self): super(TestPosixToBabel, self).setUp() - self.d = datetime.datetime(2007, 9, 8, 4, 5, 1) + # use a somewhat non-standard locale + self.test_locale = 'tr_TR' + locale.setlocale(locale.LC_ALL, self.test_locale) + locale.setlocale(locale.LC_TIME, self.test_locale) + self.d = datetime.datetime(2007, 9, 7, 4, 5, 1) + + def tearDown(self): + super(TestPosixToBabel, self).tearDown() + (code, encoding) = locale.getdefaultlocale() + locale.setlocale(locale.LC_TIME, code) + locale.setlocale(locale.LC_ALL, code) def assert_eq(self, fmt, d=None): if d is None: d = self.d - locale = babel.Locale.default('LC_TIME') + locale = babel.Locale(self.test_locale) ldml_format = misc.posix_to_ldml(fmt, locale=locale) self.assertEqual( d.strftime(fmt), @@ -69,11 +84,7 @@ class TestPosixToBabel(unittest2.TestCase): def test_escape(self): self.assert_eq("%%m:%m %%d:%d %%y:%y") - def test_xX(self): - self.assert_eq('%x %X') - def test_various_examples(self): - self.assert_eq("%x - %I:%M%p") self.assert_eq('%Y-%m-%dT%H:%M:%S') self.assert_eq("%Y-%j") self.assert_eq("%a, %d %b %Y %H:%M:%S")