Skip to content

Commit b12a54a

Browse files
committed
Use Path.touch to create files for rmtree tests
It's not necessary to use `write_bytes(b"")`, because pathlib.Path has `touch()`.
1 parent a1543fb commit b12a54a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Diff for: test/test_util.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def permission_error_tmpdir(tmp_path):
4646
"""Fixture to test permissions errors in situations where they are not overcome."""
4747
td = tmp_path / "testdir"
4848
td.mkdir()
49-
(td / "x").write_bytes(b"")
49+
(td / "x").touch()
5050

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

7878
try:
7979
rmtree(td)
@@ -95,7 +95,7 @@ def test_deletes_dir_with_readonly_files(self, tmp_path):
9595
for d in td, td / "sub":
9696
d.mkdir()
9797
for f in td / "x", td / "sub" / "y":
98-
f.write_bytes(b"")
98+
f.touch()
9999
f.chmod(0)
100100

101101
try:
@@ -115,7 +115,7 @@ def test_avoids_changing_permissions_outside_tree(self, tmp_path):
115115

116116
dir1 = tmp_path / "dir1"
117117
dir1.mkdir()
118-
(dir1 / "file").write_bytes(b"")
118+
(dir1 / "file").touch()
119119
(dir1 / "file").chmod(stat.S_IRUSR)
120120
old_mode = (dir1 / "file").stat().st_mode
121121

0 commit comments

Comments
 (0)