Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb12a54a

Browse files
committed
Use Path.touch to create files for rmtree tests
It's not necessary to use `write_bytes(b"")`, because pathlib.Pathhas `touch()`.
1 parenta1543fb commitb12a54a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

‎test/test_util.py

Lines changed: 4 additions & 4 deletions
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
fordintd,td/"sub":
9696
d.mkdir()
9797
forfintd/"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)

[8]ページ先頭

©2009-2025 Movatter.jp