diff options
author | Brett Cannon <bcannon@gmail.com> | 2003-04-27 19:42:41 (GMT) |
---|---|---|
committer | Brett Cannon <bcannon@gmail.com> | 2003-04-27 19:42:41 (GMT) |
commit | 4aebbb044942ad17d761491b46ff05b6ab8387c9 (patch) | |
tree | 22ec87f3b313f87545d3ba216baa699085d375b2 /Lib/test/test_gettext.py | |
parent | caf1c9dfe779c2a07c7d3320a9c53ca6e47c1d1b (diff) | |
download | cpython-4aebbb044942ad17d761491b46ff05b6ab8387c9.zip cpython-4aebbb044942ad17d761491b46ff05b6ab8387c9.tar.gz cpython-4aebbb044942ad17d761491b46ff05b6ab8387c9.tar.bz2 |
Make tests clean up after themselves better. This means:
* call tearDown when Setup is called
* shutil.rmtree the root of the created directory instead of just the leaf
directory
* set the LANGUAGE environment variable to what it was originally and not
assume 'en'.
Diffstat (limited to 'Lib/test/test_gettext.py')
-rw-r--r-- | Lib/test/test_gettext.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/Lib/test/test_gettext.py b/Lib/test/test_gettext.py index 81a2081..a36cd30 100644 --- a/Lib/test/test_gettext.py +++ b/Lib/test/test_gettext.py @@ -46,6 +46,10 @@ ZC1CeTogbWFudWFsbHkKAMKkeXoA LOCALEDIR = os.path.join('xx', 'LC_MESSAGES') MOFILE = os.path.join(LOCALEDIR, 'gettext.mo') UMOFILE = os.path.join(LOCALEDIR, 'ugettext.mo') +try: + LANG = os.environ['LANGUAGE'] +except: + LANG = 'en' class GettextBaseTest(unittest.TestCase): @@ -60,8 +64,8 @@ class GettextBaseTest(unittest.TestCase): os.environ['LANGUAGE'] = 'xx' def tearDown(self): - os.environ['LANGUAGE'] = 'en' - shutil.rmtree(LOCALEDIR) + os.environ['LANGUAGE'] = LANG + shutil.rmtree(os.path.split(LOCALEDIR)[0]) class GettextTestCase1(GettextBaseTest): @@ -71,6 +75,9 @@ class GettextTestCase1(GettextBaseTest): self.mofile = MOFILE gettext.install('gettext', self.localedir) + def tearDown(self): + GettextBaseTest.tearDown(self) + def test_some_translations(self): eq = self.assertEqual # test some translations @@ -137,6 +144,9 @@ class GettextTestCase2(GettextBaseTest): # For convenience self._ = gettext.gettext + def tearDown(self): + GettextBaseTest.tearDown(self) + def test_bindtextdomain(self): self.assertEqual(gettext.bindtextdomain('gettext'), self.localedir) @@ -191,6 +201,9 @@ class PluralFormsTestCase(GettextBaseTest): GettextBaseTest.setUp(self) self.mofile = MOFILE + def tearDown(self): + GettextBaseTest.tearDown(self) + def test_plural_forms1(self): eq = self.assertEqual x = gettext.ngettext('There is %s file', 'There are %s files', 1) @@ -279,6 +292,9 @@ class UnicodeTranslationsTest(GettextBaseTest): fp.close() self._ = self.t.ugettext + def tearDown(self): + GettextBaseTest.tearDown(self) + def test_unicode_msgid(self): unless = self.failUnless unless(isinstance(self._(''), unicode)) |