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

Commitb9f485f

Browse files
author
Spece
committed
#2079 Satisfy.
1 parent271328f commitb9f485f

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

‎test/test_util.py‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,13 @@
4545

4646
@pytest.fixture
4747
defpermission_error_tmpdir(tmp_path):
48-
"""Fixture to test permissions errors in situations where they are not overcome."""
48+
"""Fixture to test permissions errors when they cannot be bypassed.
49+
50+
On Unix-like systems the setup relies on running as a non-root user so that
51+
removing a read-only directory raises ``PermissionError``. When the tests
52+
execute with root privileges the expected error will not occur, so we skip
53+
them explicitly to avoid false failures.
54+
"""
4955
td=tmp_path/"testdir"
5056
td.mkdir()
5157
(td/"x").touch()
@@ -54,10 +60,13 @@ def permission_error_tmpdir(tmp_path):
5460
(td/"x").chmod(stat.S_IRUSR)
5561

5662
# Set up PermissionError on Unix, where non-root users can't delete files in
57-
# read-only directories.(Tests that rely on this and assert that rmtree raises
58-
#PermissionError will fail if they are run as root.)
63+
# read-only directories.Skip when running as root because the permission
64+
#change would not trigger the expected failure.
5965
td.chmod(stat.S_IRUSR|stat.S_IXUSR)
6066

67+
ifhasattr(os,"geteuid")andos.geteuid()==0:
68+
pytest.skip("permission_error_tmpdir requires non-root privileges to raise PermissionError")
69+
6170
yieldtd
6271

6372

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp