]> granicus.if.org Git - python/commitdiff
#5976: fixed distutils test_check_environ
authorTarek Ziadé <ziade.tarek@gmail.com>
Sat, 9 May 2009 10:06:00 +0000 (10:06 +0000)
committerTarek Ziadé <ziade.tarek@gmail.com>
Sat, 9 May 2009 10:06:00 +0000 (10:06 +0000)
Lib/distutils/tests/test_util.py
Misc/NEWS

index 348933e901c864aabd567913e8bb8ff0bce8515b..ea7c5925b79b29b98814c050948aa61777b42868 100644 (file)
@@ -214,12 +214,17 @@ class utilTestCase(unittest.TestCase):
 
         # posix without HOME
         if os.name == 'posix':  # this test won't run on windows
-            os.environ = {}
-            check_environ()
-
-            import pwd
-            self.assertEquals(os.environ['HOME'],
-                              pwd.getpwuid(os.getuid())[5])
+            old_home = os.environ.get('HOME')
+            try:
+                check_environ()
+                import pwd
+                self.assertEquals(os.environ['HOME'],
+                                  pwd.getpwuid(os.getuid())[5])
+            finally:
+                if old_home is not None:
+                    os.environ['HOME'] = old_home
+                else:
+                    del os.environ['HOME']
         else:
             check_environ()
 
index 485920a5c43c628c103929bbe61f71222ebe1d2c..7c037c38f852c33e1281f79156c2b93604815714 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -285,6 +285,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #5976: Fixed Distutils test_check_environ.
+
 - Issue #5900: Ensure RUNPATH is added to extension modules with RPATH if GNU 
   ld is used. Original patch by Floris Bruynooghe.