This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author francismb
Recipients dstufft, eric.araujo, francismb, r.david.murray
Date 2014-09-29.20:33:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1412022792.83.0.102925973698.issue22512@psf.upfronthosting.co.za>
In-reply-to
Content
Why is test.support.EnvironmentVarGuard preferable over distutils.test.support.EnvironGuard (with this one I'm not getting the warnings below)?

If I change the patch to (not so different (?) as in other tests using EnvironmentVarGuard):

$hg diff
diff -r 2b212a8186e0 Lib/distutils/tests/test_bdist_rpm.py
--- a/Lib/distutils/tests/test_bdist_rpm.py     Mon Sep 29 11:25:00 2014 -0400
+++ b/Lib/distutils/tests/test_bdist_rpm.py     Mon Sep 29 21:11:25 2014 +0200
@@ -5,7 +5,7 @@
 import os
 import tempfile
 import shutil
-from test.support import run_unittest
+from test.support import run_unittest, EnvironmentVarGuard
 
 from distutils.core import Distribution
 from distutils.command.bdist_rpm import bdist_rpm
@@ -36,8 +36,11 @@
         super(BuildRpmTestCase, self).setUp()
         self.old_location = os.getcwd()
         self.old_sys_argv = sys.argv, sys.argv[:]
+        self.env = EnvironmentVarGuard()
 
     def tearDown(self):
+        self.env.__exit__()
+        del self.env                                                                      
         os.chdir(self.old_location)                                                       
         sys.argv = self.old_sys_argv[0]                                                   
         sys.argv[:] = self.old_sys_argv[1]                                                
@@ -54,6 +57,7 @@                                                                          
     def test_quiet(self):                                                                 
         # let's create a package                                                          
         tmp_dir = self.mkdtemp()                                                          
+        self.env['HOME'] = tmp_dir   # to confine dir '.rpmdb' creation                   
         pkg_dir = os.path.join(tmp_dir, 'foo')                                            
         os.mkdir(pkg_dir)                                                                 
         self.write_file((pkg_dir, 'setup.py'), SETUP_PY)
@@ -96,6 +100,7 @@
     def test_no_optimize_flag(self):
         # let's create a package that brakes bdist_rpm
         tmp_dir = self.mkdtemp()
+        self.env['HOME'] = tmp_dir   # to confine dir '.rpmdb' creation
         pkg_dir = os.path.join(tmp_dir, 'foo')
         os.mkdir(pkg_dir)
         self.write_file((pkg_dir, 'setup.py'), SETUP_PY)

I get the message:
[102/390] test_distutils
Warning -- threading._dangling was modified by test_distutils

Using EnvironmentVarGuard as context manager gives the same warning.
History
Date User Action Args
2014-09-29 20:33:12francismbsetrecipients: + francismb, eric.araujo, r.david.murray, dstufft
2014-09-29 20:33:12francismbsetmessageid: <1412022792.83.0.102925973698.issue22512@psf.upfronthosting.co.za>
2014-09-29 20:33:12francismblinkissue22512 messages
2014-09-29 20:33:12francismbcreate