comparison test/test_dates.py @ 6650:5be4f9104cf7

Make i18n tests work These use installed roundup locales but should use the checked-out locales. Also revert monkey patches in i18n after the test.
author Ralf Schlatterbeck <rsc@runtux.com>
date Mon, 02 May 2022 13:46:58 +0200
parents 0f0cee081990
children c8a931aa7514
comparison
equal deleted inserted replaced
6649:33616bc80baf 6650:5be4f9104cf7
38 class DateTestCase(unittest.TestCase): 38 class DateTestCase(unittest.TestCase):
39 def setUp(self): 39 def setUp(self):
40 # force use of local locale directory. System locale dir 40 # force use of local locale directory. System locale dir
41 # doesn't have the locale files installed, and without wiping 41 # doesn't have the locale files installed, and without wiping
42 # the default the .mo file sometimes isn't found. 42 # the default the .mo file sometimes isn't found.
43 i18n.LOCALE_DIRS=[] 43 self.backup_domain = i18n.DOMAIN
44 i18n.LOCALE_DIRS.insert(0,"locale/locale") 44 i18n.DOMAIN = ''
45 self.backup_locale_dirs = i18n.LOCALE_DIRS
46 i18n.LOCALE_DIRS=["locale"]
45 47
46 self.old_gettext_ = i18n.gettext 48 self.old_gettext_ = i18n.gettext
47 self.old_ngettext_ = i18n.ngettext 49 self.old_ngettext_ = i18n.ngettext
48 i18n.gettext = i18n.get_translation(language='C').gettext 50 i18n.gettext = i18n.get_translation(language='C').gettext
49 i18n.degettext = i18n.get_translation(language='de').gettext 51 i18n.degettext = i18n.get_translation(language='de').gettext
51 i18n.dengettext = i18n.get_translation(language='de').ngettext 53 i18n.dengettext = i18n.get_translation(language='de').ngettext
52 54
53 def tearDown(self): 55 def tearDown(self):
54 i18n.gettext = self.old_gettext_ 56 i18n.gettext = self.old_gettext_
55 i18n.ngettext = self.old_ngettext_ 57 i18n.ngettext = self.old_ngettext_
58 i18n.LOCALE_DIRS = self.backup_locale_dirs
59 i18n.DOMAIN = self.backup_domain
56 60
57 def testDateInterval(self): 61 def testDateInterval(self):
58 ae = self.assertEqual 62 ae = self.assertEqual
59 date = Date("2000-06-26.00:34:02 + 2d") 63 date = Date("2000-06-26.00:34:02 + 2d")
60 ae(str(date), '2000-06-28.00:34:02') 64 ae(str(date), '2000-06-28.00:34:02')

Roundup Issue Tracker: http://roundup-tracker.org/