Kaydet (Commit) 4aebbb04 authored tarafından Brett Cannon's avatar Brett Cannon

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'.
üst caf1c9df
......@@ -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))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment