Skip to content

Commit 9d37e3c

Browse files
chrahuntxavfernandez
authored andcommitted
Remove rmtree from tests.lib.path.Path.
1 parent 6458099 commit 9d37e3c

File tree

4 files changed

+8
-10
lines changed

4 files changed

+8
-10
lines changed

tests/functional/test_install.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def test_pep518_with_user_pip(script, pip_src, data, common_wheels):
115115
script.pip("install", "--ignore-installed",
116116
"-f", common_wheels, "--user", pip_src)
117117
system_pip_dir = script.site_packages_path / 'pip'
118-
system_pip_dir.rmtree()
118+
assert not system_pip_dir.exists()
119119
system_pip_dir.mkdir()
120120
with open(system_pip_dir / '__init__.py', 'w') as fp:
121121
fp.write('raise ImportError\n')

tests/lib/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,10 @@ def copy(cls, root):
139139
return obj
140140

141141
def reset(self):
142-
self.root.rmtree()
142+
# Check explicitly for the target directory to avoid overly-broad
143+
# try/except.
144+
if self.root.exists():
145+
shutil.rmtree(self.root)
143146
self.source.copytree(self.root)
144147

145148
@property
@@ -948,7 +951,7 @@ def hello():
948951
generated = shutil.make_archive(retval, 'zip', script.temp_path)
949952
shutil.move(generated, retval)
950953

951-
script.temp_path.rmtree()
954+
shutil.rmtree(script.temp_path)
952955
script.temp_path.mkdir()
953956

954957
return retval

tests/lib/path.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,6 @@ def rmdir(self):
186186
"""
187187
return os.rmdir(self)
188188

189-
def rmtree(self, noerrors=True):
190-
"""
191-
Removes a directory tree. Ignores errors by default.
192-
"""
193-
return shutil.rmtree(self, ignore_errors=noerrors)
194-
195189
def copy(self, to):
196190
return shutil.copy(self, to)
197191

tests/lib/venv.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import absolute_import
22

33
import compileall
4+
import shutil
45
import sys
56
import textwrap
67

@@ -47,7 +48,7 @@ def __repr__(self):
4748

4849
def _create(self, clear=False):
4950
if clear:
50-
self.location.rmtree()
51+
shutil.rmtree(self.location)
5152
if self._template:
5253
# On Windows, calling `_virtualenv.path_locations(target)`
5354
# will have created the `target` directory...

0 commit comments

Comments
 (0)