Skip to content

Commit

Permalink
Use Path.touch to create files for rmtree tests
Browse files Browse the repository at this point in the history
It's not necessary to use `write_bytes(b"")`, because pathlib.Path
has `touch()`.
  • Loading branch information
EliahKagan committed Dec 19, 2023
1 parent a1543fb commit b12a54a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def permission_error_tmpdir(tmp_path):
"""Fixture to test permissions errors in situations where they are not overcome."""
td = tmp_path / "testdir"
td.mkdir()
(td / "x").write_bytes(b"")
(td / "x").touch()

# Set up PermissionError on Windows, where we can't delete read-only files.
(td / "x").chmod(stat.S_IRUSR)
Expand All @@ -73,7 +73,7 @@ def test_deletes_nested_dir_with_files(self, tmp_path):
td / "s" / "y",
td / "s" / "z",
):
f.write_bytes(b"")
f.touch()

try:
rmtree(td)
Expand All @@ -95,7 +95,7 @@ def test_deletes_dir_with_readonly_files(self, tmp_path):
for d in td, td / "sub":
d.mkdir()
for f in td / "x", td / "sub" / "y":
f.write_bytes(b"")
f.touch()
f.chmod(0)

try:
Expand All @@ -115,7 +115,7 @@ def test_avoids_changing_permissions_outside_tree(self, tmp_path):

dir1 = tmp_path / "dir1"
dir1.mkdir()
(dir1 / "file").write_bytes(b"")
(dir1 / "file").touch()
(dir1 / "file").chmod(stat.S_IRUSR)
old_mode = (dir1 / "file").stat().st_mode

Expand Down

0 comments on commit b12a54a

Please sign in to comment.