Message227830
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. |
|
Date |
User |
Action |
Args |
2014-09-29 20:33:12 | francismb | set | recipients:
+ francismb, eric.araujo, r.david.murray, dstufft |
2014-09-29 20:33:12 | francismb | set | messageid: <1412022792.83.0.102925973698.issue22512@psf.upfronthosting.co.za> |
2014-09-29 20:33:12 | francismb | link | issue22512 messages |
2014-09-29 20:33:12 | francismb | create | |
|