Remove rmtree from tests.lib.path.Path.

This commit is contained in:
Chris Hunt 2019-07-19 19:59:53 -04:00 committed by Xavier Fernandez
parent 645809944c
commit 9d37e3ced2
4 changed files with 8 additions and 10 deletions

View File

@ -115,7 +115,7 @@ def test_pep518_with_user_pip(script, pip_src, data, common_wheels):
script.pip("install", "--ignore-installed",
"-f", common_wheels, "--user", pip_src)
system_pip_dir = script.site_packages_path / 'pip'
system_pip_dir.rmtree()
assert not system_pip_dir.exists()
system_pip_dir.mkdir()
with open(system_pip_dir / '__init__.py', 'w') as fp:
fp.write('raise ImportError\n')

View File

@ -139,7 +139,10 @@ class TestData(object):
return obj
def reset(self):
self.root.rmtree()
# Check explicitly for the target directory to avoid overly-broad
# try/except.
if self.root.exists():
shutil.rmtree(self.root)
self.source.copytree(self.root)
@property
@ -948,7 +951,7 @@ def create_basic_wheel_for_package(script, name, version,
generated = shutil.make_archive(retval, 'zip', script.temp_path)
shutil.move(generated, retval)
script.temp_path.rmtree()
shutil.rmtree(script.temp_path)
script.temp_path.mkdir()
return retval

View File

@ -186,12 +186,6 @@ class Path(_base):
"""
return os.rmdir(self)
def rmtree(self, noerrors=True):
"""
Removes a directory tree. Ignores errors by default.
"""
return shutil.rmtree(self, ignore_errors=noerrors)
def copy(self, to):
return shutil.copy(self, to)

View File

@ -1,6 +1,7 @@
from __future__ import absolute_import
import compileall
import shutil
import sys
import textwrap
@ -47,7 +48,7 @@ class VirtualEnvironment(object):
def _create(self, clear=False):
if clear:
self.location.rmtree()
shutil.rmtree(self.location)
if self._template:
# On Windows, calling `_virtualenv.path_locations(target)`
# will have created the `target` directory...