Skip to content

Commit 34621bf

Browse files
authored
Merge pull request #6701 from pradyunsg/tests/remove-makedirs
Change Path.makedirs() -> Path.mkdir(parents=True)
2 parents 16ef685 + bc88399 commit 34621bf

File tree

7 files changed

+13
-16
lines changed

7 files changed

+13
-16
lines changed

tests/functional/test_install.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,7 @@ def test_install_editable_with_prefix(script):
896896

897897
# make sure target path is in PYTHONPATH
898898
pythonpath = script.scratch_path / site_packages
899-
pythonpath.makedirs()
899+
pythonpath.mkdir(parents=True)
900900
script.environ["PYTHONPATH"] = pythonpath
901901

902902
# install pkga package into the absolute prefix directory

tests/functional/test_uninstall_user.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def test_uninstall_editable_from_usersite(self, script, data):
5151
"""
5252
Test uninstall editable local user install
5353
"""
54-
script.user_site_path.makedirs()
54+
script.user_site_path.mkdir(parents=True)
5555

5656
# install
5757
to_install = data.packages.joinpath("FSPkg")

tests/functional/test_wheel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def auto_with_wheel(with_wheel):
1616

1717

1818
def add_files_to_dist_directory(folder):
19-
(folder / 'dist').makedirs()
19+
(folder / 'dist').mkdir(parents=True)
2020
(folder / 'dist' / 'a_name-0.0.1.tar.gz').write_text("hello")
2121
# Not adding a wheel file since that confuses setuptools' backend.
2222
# (folder / 'dist' / 'a_name-0.0.1-py2.py3-none-any.whl').write_text(

tests/lib/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ def __init__(self, base_path, *args, **kwargs):
471471

472472
# create easy-install.pth in user_site, so we always have it updated
473473
# instead of created
474-
self.user_site_path.makedirs()
474+
self.user_site_path.mkdir(parents=True)
475475
self.user_site_path.joinpath("easy-install.pth").touch()
476476

477477
def _ignore_file(self, fn):

tests/lib/path.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -161,20 +161,17 @@ def exists(self):
161161
"""
162162
return os.path.exists(self)
163163

164-
def mkdir(self, mode=0x1FF): # 0o777
164+
def mkdir(self, mode=0x1FF, parents=False): # 0o777
165165
"""
166166
Creates a directory, if it doesn't exist already.
167-
"""
168-
if not self.exists():
169-
os.mkdir(self, mode)
170-
return self
171167
172-
def makedirs(self, mode=0x1FF): # 0o777
168+
:param parents: Whether to create parent directories.
173169
"""
174-
Like mkdir(), but also creates parent directories.
175-
"""
176-
if not self.exists():
177-
os.makedirs(self, mode)
170+
if self.exists():
171+
return self
172+
173+
maker_func = os.makedirs if parents else os.mkdir
174+
maker_func(self, mode)
178175
return self
179176

180177
def unlink(self):

tests/lib/venv.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def _create(self, clear=False):
7272
context = builder.ensure_directories(self.location)
7373
builder.create_configuration(context)
7474
builder.setup_python(context)
75-
self.site.makedirs()
75+
self.site.mkdir(parents=True)
7676
self.sitecustomize = self._sitecustomize
7777
self.user_site_packages = self._user_site_packages
7878

tests/unit/test_download.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
@pytest.fixture(scope="function")
2626
def cache_tmpdir(tmpdir):
2727
cache_dir = tmpdir.joinpath("cache")
28-
cache_dir.makedirs()
28+
cache_dir.mkdir(parents=True)
2929
yield cache_dir
3030

3131

0 commit comments

Comments
 (0)