Make test.test_support.EnvironmentVarGuard behave like a dictionary.
All changes are mirrored to the underlying os.environ dict, but rolled back
on exit from the with block.
diff --git a/Lib/test/test_gettext.py b/Lib/test/test_gettext.py
index ab6bc9a..dca99cb 100644
--- a/Lib/test/test_gettext.py
+++ b/Lib/test/test_gettext.py
@@ -58,10 +58,6 @@
MOFILE = os.path.join(LOCALEDIR, 'gettext.mo')
UMOFILE = os.path.join(LOCALEDIR, 'ugettext.mo')
MMOFILE = os.path.join(LOCALEDIR, 'metadata.mo')
-try:
- LANG = os.environ['LANGUAGE']
-except:
- LANG = 'en'
class GettextBaseTest(unittest.TestCase):
@@ -77,10 +73,12 @@
fp = open(MMOFILE, 'wb')
fp.write(base64.decodestring(MMO_DATA))
fp.close()
- os.environ['LANGUAGE'] = 'xx'
+ self.env = test_support.EnvironmentVarGuard()
+ self.env['LANGUAGE'] = 'xx'
def tearDown(self):
- os.environ['LANGUAGE'] = LANG
+ self.env.__exit__()
+ del self.env
shutil.rmtree(os.path.split(LOCALEDIR)[0])