115
115
MMOFILE = os .path .join (LOCALEDIR , 'metadata.mo' )
116
116
117
117
118
+ def reset_gettext ():
119
+ gettext ._localedirs .clear ()
120
+ gettext ._current_domain = 'messages'
121
+ gettext ._translations .clear ()
122
+
123
+
118
124
class GettextBaseTest (unittest .TestCase ):
119
125
def setUp (self ):
120
126
self .addCleanup (os_helper .rmtree , os .path .split (LOCALEDIR )[0 ])
@@ -132,7 +138,8 @@ def setUp(self):
132
138
fp .write (base64 .decodebytes (MMO_DATA ))
133
139
self .env = self .enterContext (os_helper .EnvironmentVarGuard ())
134
140
self .env ['LANGUAGE' ] = 'xx'
135
- gettext ._translations .clear ()
141
+ reset_gettext ()
142
+ self .addCleanup (reset_gettext )
136
143
137
144
138
145
GNU_MO_DATA_ISSUE_17898 = b'''\
@@ -312,6 +319,10 @@ def test_multiline_strings(self):
312
319
class PluralFormsTestCase (GettextBaseTest ):
313
320
def setUp (self ):
314
321
GettextBaseTest .setUp (self )
322
+ self .localedir = os .curdir
323
+ # Set up the bindings
324
+ gettext .bindtextdomain ('gettext' , self .localedir )
325
+ gettext .textdomain ('gettext' )
315
326
self .mofile = MOFILE
316
327
317
328
def test_plural_forms1 (self ):
@@ -355,7 +366,7 @@ def test_plural_context_forms2(self):
355
366
x = t .npgettext ('With context' ,
356
367
'There is %s file' , 'There are %s files' , 2 )
357
368
eq (x , 'Hay %s ficheros (context)' )
358
- x = gettext .pgettext ('With context' , 'There is %s file' )
369
+ x = t .pgettext ('With context' , 'There is %s file' )
359
370
eq (x , 'Hay %s fichero (context)' )
360
371
361
372
# Examples from http://www.gnu.org/software/gettext/manual/gettext.html
0 commit comments