mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
Changed distutils tests to avoid environment alteration
This commit is contained in:
parent
11abfe640f
commit
2b06d42db5
13 changed files with 67 additions and 34 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue