Skip to content

Commit 065d032

Browse files
committed
Better names for locals of on_rm_rf_error
1 parent 6a6eb79 commit 065d032

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/_pytest/pathlib.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,19 @@ def ensure_reset_dir(path):
3939
path.mkdir()
4040

4141

42-
def on_rm_rf_error(func, epath: str, exc, *, startpath):
42+
def on_rm_rf_error(func, path: str, exc, *, start_path):
4343
"""Handles known read-only errors during rmtree."""
4444
excvalue = exc[1]
4545

4646
if not isinstance(excvalue, PermissionError):
4747
warnings.warn(
48-
PytestWarning("(rm_rf) error removing {}: {}".format(epath, excvalue))
48+
PytestWarning("(rm_rf) error removing {}: {}".format(path, excvalue))
4949
)
5050
return
5151

5252
if func not in (os.rmdir, os.remove, os.unlink):
5353
warnings.warn(
54-
PytestWarning("(rm_rf) error removing {}: {}".format(epath, excvalue))
54+
PytestWarning("(rm_rf) error removing {}: {}".format(path, excvalue))
5555
)
5656
return
5757

@@ -64,23 +64,23 @@ def chmod_rw(p: str):
6464

6565
# For files, we need to recursively go upwards in the directories to
6666
# ensure they all are also writable.
67-
p = Path(epath)
67+
p = Path(path)
6868
if p.is_file():
6969
for parent in p.parents:
7070
chmod_rw(str(parent))
7171
# stop when we reach the original path passed to rm_rf
72-
if parent == startpath:
72+
if parent == start_path:
7373
break
74-
chmod_rw(str(epath))
74+
chmod_rw(str(path))
7575

76-
func(epath)
76+
func(path)
7777

7878

7979
def rm_rf(path: Path):
8080
"""Remove the path contents recursively, even if some elements
8181
are read-only.
8282
"""
83-
onerror = partial(on_rm_rf_error, startpath=path)
83+
onerror = partial(on_rm_rf_error, start_path=path)
8484
shutil.rmtree(str(path), onerror=onerror)
8585

8686

testing/test_tmpdir.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,17 +387,17 @@ def test_on_rm_rf_error(self, tmp_path):
387387
# unknown exception
388388
with pytest.warns(pytest.PytestWarning):
389389
exc_info = (None, RuntimeError(), None)
390-
on_rm_rf_error(os.unlink, fn, exc_info, startpath=tmp_path)
390+
on_rm_rf_error(os.unlink, fn, exc_info, start_path=tmp_path)
391391
assert fn.is_file()
392392

393393
# unknown function
394394
with pytest.warns(pytest.PytestWarning):
395395
exc_info = (None, PermissionError(), None)
396-
on_rm_rf_error(None, fn, exc_info, startpath=tmp_path)
396+
on_rm_rf_error(None, fn, exc_info, start_path=tmp_path)
397397
assert fn.is_file()
398398

399399
exc_info = (None, PermissionError(), None)
400-
on_rm_rf_error(os.unlink, fn, exc_info, startpath=tmp_path)
400+
on_rm_rf_error(os.unlink, fn, exc_info, start_path=tmp_path)
401401
assert not fn.is_file()
402402

403403

0 commit comments

Comments
 (0)