Francis MB added the comment:

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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue22512>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to