Commit a440b1ce authored by Tarek Ziadé's avatar Tarek Ziadé

refactored test_sysconfig so it uses test.test_support.EnvironmentVarGuard

parent a7de6ba0
...@@ -5,6 +5,7 @@ import tempfile ...@@ -5,6 +5,7 @@ import tempfile
from distutils import log from distutils import log
from distutils.core import Distribution from distutils.core import Distribution
from test.test_support import EnvironmentVarGuard
class LoggingSilencer(object): class LoggingSilencer(object):
...@@ -82,3 +83,13 @@ class DummyCommand: ...@@ -82,3 +83,13 @@ class DummyCommand:
def ensure_finalized(self): def ensure_finalized(self):
pass pass
class EnvironGuard(object):
def setUp(self):
super(EnvironGuard, self).setUp()
self.environ = EnvironmentVarGuard()
def tearDown(self):
self.environ.__exit__()
super(EnvironGuard, self).tearDown()
"""Tests for distutils.dist.""" """Tests for distutils.sysconfig."""
from distutils import sysconfig
from distutils.ccompiler import get_default_compiler
import os import os
import unittest import unittest
from distutils import sysconfig
from distutils.ccompiler import get_default_compiler
from distutils.tests import support
from test.test_support import TESTFN from test.test_support import TESTFN
class SysconfigTestCase(unittest.TestCase): class SysconfigTestCase(support.EnvironGuard,
unittest.TestCase):
def setUp(self):
self.old_flags = [('AR', os.environ.get('AR')),
('ARFLAGS', os.environ.get('ARFLAGS'))]
def tearDown(self):
for name, value in self.old_flags:
if value is not None:
os.environ[name] = value
elif name in os.environ:
del os.environ[name]
def test_get_config_h_filename(self): def test_get_config_h_filename(self):
config_h = sysconfig.get_config_h_filename() config_h = sysconfig.get_config_h_filename()
...@@ -53,8 +42,8 @@ class SysconfigTestCase(unittest.TestCase): ...@@ -53,8 +42,8 @@ class SysconfigTestCase(unittest.TestCase):
if get_default_compiler() != 'unix': if get_default_compiler() != 'unix':
return return
os.environ['AR'] = 'my_ar' self.environ['AR'] = 'my_ar'
os.environ['ARFLAGS'] = '-arflags' self.environ['ARFLAGS'] = '-arflags'
# make sure AR gets caught # make sure AR gets caught
class compiler: class compiler:
......
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