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

Commit4023f28

Browse files
authored
Merge pull request#1774 from EliahKagan/simplify-test-util
Run some Windows environment variable tests only on Windows
2 parentsa1543fb +6a8ed70 commit4023f28

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

‎test/test_util.py

Lines changed: 15 additions & 11 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

@@ -207,24 +207,28 @@ def _run_parse(name, value):
207207
)
208208
returnast.literal_eval(output)
209209

210+
@pytest.mark.skipif(
211+
os.name!="nt",
212+
reason="These environment variables are only used on Windows.",
213+
)
210214
@pytest.mark.parametrize(
211215
"env_var_value, expected_truth_value",
212216
[
213-
(None,os.name=="nt"),#True on Windows when the environment variable is unset.
217+
(None,True),#When the environment variable is unset.
214218
("",False),
215219
(" ",False),
216220
("0",False),
217-
("1",os.name=="nt"),
221+
("1",True),
218222
("false",False),
219-
("true",os.name=="nt"),
223+
("true",True),
220224
("False",False),
221-
("True",os.name=="nt"),
225+
("True",True),
222226
("no",False),
223-
("yes",os.name=="nt"),
227+
("yes",True),
224228
("NO",False),
225-
("YES",os.name=="nt"),
229+
("YES",True),
226230
(" no ",False),
227-
(" yes ",os.name=="nt"),
231+
(" yes ",True),
228232
],
229233
)
230234
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp