summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-05-02 11:11:50 (GMT)
committerGitHub <noreply@github.com>2017-05-02 11:11:50 (GMT)
commit92fd6c9ef54a857815e3dca8ee74b2b4f5cdf154 (patch)
tree84b747fc0fd8154d8375c64c326f7f075e7bc16c
parentd4069de5112f0408801ff2479476827bb3e0e8fc (diff)
downloadcpython-92fd6c9ef54a857815e3dca8ee74b2b4f5cdf154.zip
cpython-92fd6c9ef54a857815e3dca8ee74b2b4f5cdf154.tar.gz
cpython-92fd6c9ef54a857815e3dca8ee74b2b4f5cdf154.tar.bz2
bpo-30132: distutils BuildExtTestCase use temp_cwd (#1380)
BuildExtTestCase of test_distutils now uses support.temp_cwd() in setUp() to remove files created in the current working in all BuildExtTestCase unit tests, not only test_build_ext(). Move also tearDown() just after setUp().
-rw-r--r--Lib/distutils/tests/test_build_ext.py36
1 files changed, 18 insertions, 18 deletions
diff --git a/Lib/distutils/tests/test_build_ext.py b/Lib/distutils/tests/test_build_ext.py
index 96e5f03..a722182 100644
--- a/Lib/distutils/tests/test_build_ext.py
+++ b/Lib/distutils/tests/test_build_ext.py
@@ -37,17 +37,28 @@ class BuildExtTestCase(TempdirManager,
from distutils.command import build_ext
build_ext.USER_BASE = site.USER_BASE
- def build_ext(self, *args, **kwargs):
- return build_ext(*args, **kwargs)
-
- def test_build_ext(self):
# bpo-30132: On Windows, a .pdb file may be created in the current
# working directory. Create a temporary working directory to cleanup
# everything at the end of the test.
- with support.temp_cwd():
- self._test_build_ext()
+ self.temp_cwd = support.temp_cwd()
+ self.temp_cwd.__enter__()
+ self.addCleanup(self.temp_cwd.__exit__, None, None, None)
+
+ def tearDown(self):
+ # Get everything back to normal
+ support.unload('xx')
+ sys.path = self.sys_path[0]
+ sys.path[:] = self.sys_path[1]
+ import site
+ site.USER_BASE = self.old_user_base
+ from distutils.command import build_ext
+ build_ext.USER_BASE = self.old_user_base
+ super(BuildExtTestCase, self).tearDown()
- def _test_build_ext(self):
+ def build_ext(self, *args, **kwargs):
+ return build_ext(*args, **kwargs)
+
+ def test_build_ext(self):
cmd = support.missing_compiler_executable()
if cmd is not None:
self.skipTest('The %r command is not found' % cmd)
@@ -91,17 +102,6 @@ class BuildExtTestCase(TempdirManager,
self.assertIsInstance(xx.Null(), xx.Null)
self.assertIsInstance(xx.Str(), xx.Str)
- def tearDown(self):
- # Get everything back to normal
- support.unload('xx')
- sys.path = self.sys_path[0]
- sys.path[:] = self.sys_path[1]
- import site
- site.USER_BASE = self.old_user_base
- from distutils.command import build_ext
- build_ext.USER_BASE = self.old_user_base
- super(BuildExtTestCase, self).tearDown()
-
def test_solaris_enable_shared(self):
dist = Distribution({'name': 'xx'})
cmd = self.build_ext(dist)