Skip to content

Commit 21668ac

Browse files
author
Richard Jones
committed
force tests checking text output to work in the "C" locale
1 parent a873e34 commit 21668ac

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

test/db_test_base.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
from roundup.hyperdb import String, Password, Link, Multilink, Date, \
2525
Interval, DatabaseError, Boolean, Number, Node
2626
from roundup.mailer import Mailer
27-
from roundup import date, password, init, instance, configuration, support
27+
from roundup import date, password, init, instance, configuration, \
28+
roundupdb, i18n
2829

2930
from mocknull import MockNull
3031

@@ -1834,6 +1835,8 @@ def testNosyMail(self) :
18341835
"""Creates one issue with two attachments, one smaller and one larger
18351836
than the set max_attachment_size.
18361837
"""
1838+
old_translate_ = roundupdb._
1839+
roundupdb._ = i18n.get_translation(language='C').gettext
18371840
db = self.db
18381841
db.config.NOSY_MAX_ATTACHMENT_SIZE = 4096
18391842
res = dict(mail_to = None, mail_msg = None)
@@ -1860,6 +1863,7 @@ def dummy_snd(s, to, msg, res=res) :
18601863
self.assert_("File 'test2.txt' not attached" in mail_msg)
18611864
self.assert_(base64.encodestring("yyy").rstrip() not in mail_msg)
18621865
finally :
1866+
roundupdb._ = old_translate_
18631867
Mailer.smtp_send = backup
18641868

18651869
class ROTest(MyTestCase):

test/test_dates.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,21 @@
2323
import datetime
2424
import calendar
2525

26+
from roundup import date, i18n
2627
from roundup.date import Date, Interval, Range, fixTimeOverflow, \
2728
get_timezone
2829

2930

3031
class DateTestCase(unittest.TestCase):
32+
def setUp(self):
33+
self.old_gettext_ = i18n.gettext
34+
self.old_ngettext_ = i18n.ngettext
35+
i18n.gettext = i18n.get_translation(language='C').gettext
36+
i18n.ngettext = i18n.get_translation(language='C').ngettext
37+
38+
def tearDown(self):
39+
i18n.gettext = self.old_gettext_
40+
i18n.ngettext = self.old_ngettext_
3141

3242
def testDateInterval(self):
3343
ae = self.assertEqual

test/test_mailgw.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
os.environ['SENDMAILDEBUG'] = 'mail-test.log'
2222
SENDMAILDEBUG = os.environ['SENDMAILDEBUG']
2323

24+
from roundup import mailgw, i18n, roundupdb
2425
from roundup.mailgw import MailGW, Unauthorized, uidFromAddress, \
2526
parseContent, IgnoreLoop, IgnoreBulk, MailUsageError, MailUsageHelp
2627
from roundup import init, instance, password, rfc2822, __version__
@@ -119,6 +120,8 @@ class MailgwTestCase(unittest.TestCase, DiffHelper):
119120
count = 0
120121
schema = 'classic'
121122
def setUp(self):
123+
self.old_translate_ = mailgw._
124+
roundupdb._ = mailgw._ = i18n.get_translation(language='C').gettext
122125
MailgwTestCase.count = MailgwTestCase.count + 1
123126

124127
# and open the database / "instance"
@@ -141,6 +144,7 @@ def setUp(self):
141144
address='[email protected]', roles='User')
142145

143146
def tearDown(self):
147+
roundupdb._ = mailgw._ = self.old_translate_
144148
if os.path.exists(SENDMAILDEBUG):
145149
os.remove(SENDMAILDEBUG)
146150
self.db.close()

0 commit comments

Comments
 (0)