[Python-checkins] r72539 - in python/trunk/Lib/distutils/tests: support.py test_sysconfig.py
tarek.ziade
python-checkins at python.org
Sun May 10 13:59:30 CEST 2009
Author: tarek.ziade
Date: Sun May 10 13:59:30 2009
New Revision: 72539
Log:
refactored test_sysconfig so it uses test.test_support.EnvironmentVarGuard
Modified:
python/trunk/Lib/distutils/tests/support.py
python/trunk/Lib/distutils/tests/test_sysconfig.py
Modified: python/trunk/Lib/distutils/tests/support.py
==============================================================================
--- python/trunk/Lib/distutils/tests/support.py (original)
+++ python/trunk/Lib/distutils/tests/support.py Sun May 10 13:59:30 2009
@@ -5,6 +5,7 @@
from distutils import log
from distutils.core import Distribution
+from test.test_support import EnvironmentVarGuard
class LoggingSilencer(object):
@@ -82,3 +83,13 @@
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()
Modified: python/trunk/Lib/distutils/tests/test_sysconfig.py
==============================================================================
--- python/trunk/Lib/distutils/tests/test_sysconfig.py (original)
+++ python/trunk/Lib/distutils/tests/test_sysconfig.py Sun May 10 13:59:30 2009
@@ -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 @@
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:
More information about the Python-checkins
mailing list