115115MMOFILE = os .path .join (LOCALEDIR , 'metadata.mo' )
116116
117117
118+ def reset_gettext ():
119+ gettext ._localedirs .clear ()
120+ gettext ._current_domain = 'messages'
121+ gettext ._translations .clear ()
122+
123+
118124class GettextBaseTest (unittest .TestCase ):
119125 def setUp (self ):
120126 self .addCleanup (os_helper .rmtree , os .path .split (LOCALEDIR )[0 ])
@@ -132,7 +138,8 @@ def setUp(self):
132138 fp .write (base64 .decodebytes (MMO_DATA ))
133139 self .env = self .enterContext (os_helper .EnvironmentVarGuard ())
134140 self .env ['LANGUAGE' ] = 'xx'
135- gettext ._translations .clear ()
141+ reset_gettext ()
142+ self .addCleanup (reset_gettext )
136143
137144
138145GNU_MO_DATA_ISSUE_17898 = b'''\
@@ -312,6 +319,10 @@ def test_multiline_strings(self):
312319class PluralFormsTestCase (GettextBaseTest ):
313320 def setUp (self ):
314321 GettextBaseTest .setUp (self )
322+ self .localedir = os .curdir
323+ # Set up the bindings
324+ gettext .bindtextdomain ('gettext' , self .localedir )
325+ gettext .textdomain ('gettext' )
315326 self .mofile = MOFILE
316327
317328 def test_plural_forms1 (self ):
@@ -355,7 +366,7 @@ def test_plural_context_forms2(self):
355366 x = t .npgettext ('With context' ,
356367 'There is %s file' , 'There are %s files' , 2 )
357368 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' )
359370 eq (x , 'Hay %s fichero (context)' )
360371
361372 # Examples from http://www.gnu.org/software/gettext/manual/gettext.html
0 commit comments