summaryrefslogtreecommitdiffstats
path: root/Lib/packaging
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-06-17 10:20:46 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-06-17 10:20:46 (GMT)
commitac6602bdc17973c121ea6cce9ae6768a9e5db8c3 (patch)
tree25ceaadd46f79621d7528e86d35754e85db71792 /Lib/packaging
parentac05945346723b96bbe3c5c4bb6e7905aa64b1fd (diff)
downloadcpython-ac6602bdc17973c121ea6cce9ae6768a9e5db8c3.zip
cpython-ac6602bdc17973c121ea6cce9ae6768a9e5db8c3.tar.gz
cpython-ac6602bdc17973c121ea6cce9ae6768a9e5db8c3.tar.bz2
Issue #12333: restore the previous dir before removing the current directory
packaging.tests.support.TempdirManager: removing the current directory is not allowed on Windows or Solaris. Store the current directory and restore it before removing the temporary directory (which is used as the working directory during the tests).
Diffstat (limited to 'Lib/packaging')
-rw-r--r--Lib/packaging/tests/support.py13
1 files changed, 5 insertions, 8 deletions
diff --git a/Lib/packaging/tests/support.py b/Lib/packaging/tests/support.py
index 501f126..47ce513 100644
--- a/Lib/packaging/tests/support.py
+++ b/Lib/packaging/tests/support.py
@@ -37,7 +37,7 @@ import tempfile
from packaging import logger
from packaging.dist import Distribution
from packaging.tests import unittest
-from test.support import requires_zlib
+from test.support import requires_zlib, unlink
__all__ = ['LoggingCatcher', 'TempdirManager', 'EnvironRestorer',
'DummyCommand', 'unittest', 'create_distribution',
@@ -121,20 +121,17 @@ class TempdirManager:
def setUp(self):
super(TempdirManager, self).setUp()
+ self._olddir = os.getcwd()
self._basetempdir = tempfile.mkdtemp()
self._files = []
def tearDown(self):
- shutil.rmtree(self._basetempdir, os.name in ('nt', 'cygwin'))
+ os.chdir(self._olddir)
+ shutil.rmtree(self._basetempdir)
for handle, name in self._files:
handle.close()
- if os.path.exists(name):
- try:
- os.remove(name)
- except OSError as exc:
- if exc.errno != errno.ENOENT:
- raise
+ unlink(name)
super(TempdirManager, self).tearDown()