diff options
author | Tarek Ziadé <ziade.tarek@gmail.com> | 2009-05-10 11:59:30 (GMT) |
---|---|---|
committer | Tarek Ziadé <ziade.tarek@gmail.com> | 2009-05-10 11:59:30 (GMT) |
commit | d35f2a33d54712dbb894378fe7c64903c2c4f185 (patch) | |
tree | c46de97725e0e5d367abcc0c2c9bc1ff743b6d77 /Lib/distutils/tests | |
parent | 234ab8fc1cb0be1f1025a86001507ea4c354aec7 (diff) | |
download | cpython-d35f2a33d54712dbb894378fe7c64903c2c4f185.zip cpython-d35f2a33d54712dbb894378fe7c64903c2c4f185.tar.gz cpython-d35f2a33d54712dbb894378fe7c64903c2c4f185.tar.bz2 |
refactored test_sysconfig so it uses test.test_support.EnvironmentVarGuard
Diffstat (limited to 'Lib/distutils/tests')
-rw-r--r-- | Lib/distutils/tests/support.py | 11 | ||||
-rw-r--r-- | Lib/distutils/tests/test_sysconfig.py | 27 |
2 files changed, 19 insertions, 19 deletions
diff --git a/Lib/distutils/tests/support.py b/Lib/distutils/tests/support.py index 578cf40..668edf9 100644 --- a/Lib/distutils/tests/support.py +++ b/Lib/distutils/tests/support.py @@ -5,6 +5,7 @@ import tempfile from distutils import log from distutils.core import Distribution +from test.test_support import EnvironmentVarGuard class LoggingSilencer(object): @@ -82,3 +83,13 @@ class DummyCommand: def ensure_finalized(self): pass + +class EnvironGuard(object): + + def setUp(self): + super(EnvironGuard, self).setUp() + self.environ = EnvironmentVarGuard() + + def tearDown(self): + self.environ.__exit__() + super(EnvironGuard, self).tearDown() diff --git a/Lib/distutils/tests/test_sysconfig.py b/Lib/distutils/tests/test_sysconfig.py index bf0043a..0a5ac29 100644 --- a/Lib/distutils/tests/test_sysconfig.py +++ b/Lib/distutils/tests/test_sysconfig.py @@ -1,25 +1,14 @@ -"""Tests for distutils.dist.""" - -from distutils import sysconfig -from distutils.ccompiler import get_default_compiler - +"""Tests for distutils.sysconfig.""" import os import unittest +from distutils import sysconfig +from distutils.ccompiler import get_default_compiler +from distutils.tests import support from test.test_support import TESTFN -class SysconfigTestCase(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] +class SysconfigTestCase(support.EnvironGuard, + unittest.TestCase): def test_get_config_h_filename(self): config_h = sysconfig.get_config_h_filename() @@ -53,8 +42,8 @@ class SysconfigTestCase(unittest.TestCase): if get_default_compiler() != 'unix': return - os.environ['AR'] = 'my_ar' - os.environ['ARFLAGS'] = '-arflags' + self.environ['AR'] = 'my_ar' + self.environ['ARFLAGS'] = '-arflags' # make sure AR gets caught class compiler: |