From bc88399d07314f845b9fdabc927959ca1d2e89cd Mon Sep 17 00:00:00 2001 From: Pradyun Gedam Date: Fri, 12 Jul 2019 13:30:18 +0530 Subject: [PATCH] Change Path.makedirs() -> Path.mkdir(parents=True) --- tests/functional/test_install.py | 2 +- tests/functional/test_uninstall_user.py | 2 +- tests/functional/test_wheel.py | 2 +- tests/lib/__init__.py | 2 +- tests/lib/path.py | 17 +++++++---------- tests/lib/venv.py | 2 +- tests/unit/test_download.py | 2 +- 7 files changed, 13 insertions(+), 16 deletions(-) diff --git a/tests/functional/test_install.py b/tests/functional/test_install.py index 0fa89c66c..3a945710e 100644 --- a/tests/functional/test_install.py +++ b/tests/functional/test_install.py @@ -896,7 +896,7 @@ def test_install_editable_with_prefix(script): # make sure target path is in PYTHONPATH pythonpath = script.scratch_path / site_packages - pythonpath.makedirs() + pythonpath.mkdir(parents=True) script.environ["PYTHONPATH"] = pythonpath # install pkga package into the absolute prefix directory diff --git a/tests/functional/test_uninstall_user.py b/tests/functional/test_uninstall_user.py index 5ca264c6a..aa37c205f 100644 --- a/tests/functional/test_uninstall_user.py +++ b/tests/functional/test_uninstall_user.py @@ -51,7 +51,7 @@ class Tests_UninstallUserSite: """ Test uninstall editable local user install """ - script.user_site_path.makedirs() + script.user_site_path.mkdir(parents=True) # install to_install = data.packages.joinpath("FSPkg") diff --git a/tests/functional/test_wheel.py b/tests/functional/test_wheel.py index 6192d3f55..a1d11221c 100644 --- a/tests/functional/test_wheel.py +++ b/tests/functional/test_wheel.py @@ -16,7 +16,7 @@ def auto_with_wheel(with_wheel): def add_files_to_dist_directory(folder): - (folder / 'dist').makedirs() + (folder / 'dist').mkdir(parents=True) (folder / 'dist' / 'a_name-0.0.1.tar.gz').write_text("hello") # Not adding a wheel file since that confuses setuptools' backend. # (folder / 'dist' / 'a_name-0.0.1-py2.py3-none-any.whl').write_text( diff --git a/tests/lib/__init__.py b/tests/lib/__init__.py index 6c6a49055..ca0d0c37d 100644 --- a/tests/lib/__init__.py +++ b/tests/lib/__init__.py @@ -471,7 +471,7 @@ class PipTestEnvironment(TestFileEnvironment): # create easy-install.pth in user_site, so we always have it updated # instead of created - self.user_site_path.makedirs() + self.user_site_path.mkdir(parents=True) self.user_site_path.joinpath("easy-install.pth").touch() def _ignore_file(self, fn): diff --git a/tests/lib/path.py b/tests/lib/path.py index ff5a74d9e..c6b8e7704 100644 --- a/tests/lib/path.py +++ b/tests/lib/path.py @@ -161,20 +161,17 @@ class Path(_base): """ return os.path.exists(self) - def mkdir(self, mode=0x1FF): # 0o777 + def mkdir(self, mode=0x1FF, parents=False): # 0o777 """ Creates a directory, if it doesn't exist already. - """ - if not self.exists(): - os.mkdir(self, mode) - return self - def makedirs(self, mode=0x1FF): # 0o777 + :param parents: Whether to create parent directories. """ - Like mkdir(), but also creates parent directories. - """ - if not self.exists(): - os.makedirs(self, mode) + if self.exists(): + return self + + maker_func = os.makedirs if parents else os.mkdir + maker_func(self, mode) return self def unlink(self): diff --git a/tests/lib/venv.py b/tests/lib/venv.py index 3ed1370e3..ba456785d 100644 --- a/tests/lib/venv.py +++ b/tests/lib/venv.py @@ -72,7 +72,7 @@ class VirtualEnvironment(object): context = builder.ensure_directories(self.location) builder.create_configuration(context) builder.setup_python(context) - self.site.makedirs() + self.site.mkdir(parents=True) self.sitecustomize = self._sitecustomize self.user_site_packages = self._user_site_packages diff --git a/tests/unit/test_download.py b/tests/unit/test_download.py index e183b92e2..7b421a7d7 100644 --- a/tests/unit/test_download.py +++ b/tests/unit/test_download.py @@ -25,7 +25,7 @@ from tests.lib import create_file @pytest.fixture(scope="function") def cache_tmpdir(tmpdir): cache_dir = tmpdir.joinpath("cache") - cache_dir.makedirs() + cache_dir.mkdir(parents=True) yield cache_dir -- GitLab