1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00

Merge pull request #6701 from pradyunsg/tests/remove-makedirs

Change Path.makedirs() -> Path.mkdir(parents=True)
This commit is contained in:
Pradyun Gedam 2019-07-13 16:53:41 +05:30 committed by GitHub
commit 34621bf008
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 13 additions and 16 deletions

View file

@ -896,7 +896,7 @@ def test_install_editable_with_prefix(script):
# make sure target path is in PYTHONPATH # make sure target path is in PYTHONPATH
pythonpath = script.scratch_path / site_packages pythonpath = script.scratch_path / site_packages
pythonpath.makedirs() pythonpath.mkdir(parents=True)
script.environ["PYTHONPATH"] = pythonpath script.environ["PYTHONPATH"] = pythonpath
# install pkga package into the absolute prefix directory # install pkga package into the absolute prefix directory

View file

@ -51,7 +51,7 @@ class Tests_UninstallUserSite:
""" """
Test uninstall editable local user install Test uninstall editable local user install
""" """
script.user_site_path.makedirs() script.user_site_path.mkdir(parents=True)
# install # install
to_install = data.packages.joinpath("FSPkg") to_install = data.packages.joinpath("FSPkg")

View file

@ -16,7 +16,7 @@ def auto_with_wheel(with_wheel):
def add_files_to_dist_directory(folder): 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") (folder / 'dist' / 'a_name-0.0.1.tar.gz').write_text("hello")
# Not adding a wheel file since that confuses setuptools' backend. # Not adding a wheel file since that confuses setuptools' backend.
# (folder / 'dist' / 'a_name-0.0.1-py2.py3-none-any.whl').write_text( # (folder / 'dist' / 'a_name-0.0.1-py2.py3-none-any.whl').write_text(

View file

@ -471,7 +471,7 @@ class PipTestEnvironment(TestFileEnvironment):
# create easy-install.pth in user_site, so we always have it updated # create easy-install.pth in user_site, so we always have it updated
# instead of created # instead of created
self.user_site_path.makedirs() self.user_site_path.mkdir(parents=True)
self.user_site_path.joinpath("easy-install.pth").touch() self.user_site_path.joinpath("easy-install.pth").touch()
def _ignore_file(self, fn): def _ignore_file(self, fn):

View file

@ -161,20 +161,17 @@ class Path(_base):
""" """
return os.path.exists(self) 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. Creates a directory, if it doesn't exist already.
:param parents: Whether to create parent directories.
""" """
if not self.exists(): if self.exists():
os.mkdir(self, mode)
return self return self
def makedirs(self, mode=0x1FF): # 0o777 maker_func = os.makedirs if parents else os.mkdir
""" maker_func(self, mode)
Like mkdir(), but also creates parent directories.
"""
if not self.exists():
os.makedirs(self, mode)
return self return self
def unlink(self): def unlink(self):

View file

@ -72,7 +72,7 @@ class VirtualEnvironment(object):
context = builder.ensure_directories(self.location) context = builder.ensure_directories(self.location)
builder.create_configuration(context) builder.create_configuration(context)
builder.setup_python(context) builder.setup_python(context)
self.site.makedirs() self.site.mkdir(parents=True)
self.sitecustomize = self._sitecustomize self.sitecustomize = self._sitecustomize
self.user_site_packages = self._user_site_packages self.user_site_packages = self._user_site_packages

View file

@ -25,7 +25,7 @@ from tests.lib import create_file
@pytest.fixture(scope="function") @pytest.fixture(scope="function")
def cache_tmpdir(tmpdir): def cache_tmpdir(tmpdir):
cache_dir = tmpdir.joinpath("cache") cache_dir = tmpdir.joinpath("cache")
cache_dir.makedirs() cache_dir.mkdir(parents=True)
yield cache_dir yield cache_dir