Changed distutils tests to avoid environment alteration

This commit is contained in:
Tarek Ziadé 2009-10-18 09:28:26 +00:00
parent 11abfe640f
commit 2b06d42db5
13 changed files with 67 additions and 34 deletions

View file

@ -2,11 +2,11 @@
import os
import shutil
import tempfile
from copy import deepcopy
from distutils import log
from distutils.log import DEBUG, INFO, WARN, ERROR, FATAL
from distutils.core import Distribution
from test.test_support import EnvironmentVarGuard
class LoggingSilencer(object):
@ -111,8 +111,15 @@ class EnvironGuard(object):
def setUp(self):
super(EnvironGuard, self).setUp()
self.environ = EnvironmentVarGuard()
self.old_environ = deepcopy(os.environ)
def tearDown(self):
self.environ.__exit__()
for key, value in self.old_environ.items():
if os.environ.get(key) != value:
os.environ[key] = value
for key in os.environ.keys():
if key not in self.old_environ:
del os.environ[key]
super(EnvironGuard, self).tearDown()