]> granicus.if.org Git - python/commitdiff
Merged revisions 72539 via svnmerge from
authorTarek Ziadé <ziade.tarek@gmail.com>
Sun, 10 May 2009 12:02:35 +0000 (12:02 +0000)
committerTarek Ziadé <ziade.tarek@gmail.com>
Sun, 10 May 2009 12:02:35 +0000 (12:02 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r72539 | tarek.ziade | 2009-05-10 13:59:30 +0200 (Sun, 10 May 2009) | 1 line

  refactored test_sysconfig so it uses test.test_support.EnvironmentVarGuard
........

Lib/distutils/tests/support.py
Lib/distutils/tests/test_sysconfig.py

index ab2af9a6aa186bce04dd09fcb36cbee4ccd5e03e..cdcbc3786233aa6303dc5ca168aab6e67bff3ce5 100644 (file)
@@ -5,6 +5,7 @@ import tempfile
 
 from distutils import log
 from distutils.core import Distribution
+from 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()
index f65bc725c68198d71d3414c400c4ea0dd106ed9e..322df39cf569fd97a85ff711327d692cf632546e 100644 (file)
@@ -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.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: