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

Commit2fb8c64

Browse files
committed
Move permission_error_tmpdir skips to test cases
This moves test skipping logic from the permission_error_tmpdirfixture to the two TestRmtree test case methods that use it.This produces some duplication, which is undesirable, but it makesit so that which tests are skipped under what conditions isimmediately clear, easy to identify as skipping logic (which isusually achieved by decoration), and clear in its relationshipto the skipping logic associated with other TestRmtree test cases.
1 parentaa1799f commit2fb8c64

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

‎test/test_util.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@
4646
@pytest.fixture
4747
defpermission_error_tmpdir(tmp_path):
4848
"""Fixture to test permissions errors situations where they are not overcome."""
49-
ifsys.platform=="cygwin":
50-
raiseSkipTest("Cygwin can't set the permissions that make the test meaningful.")
51-
ifsys.version_info< (3,8):
52-
raiseSkipTest("In 3.7, TemporaryDirectory doesn't clean up after weird permissions.")
53-
5449
td=tmp_path/"testdir"
5550
td.mkdir()
5651
(td/"x").write_bytes(b"")
@@ -107,6 +102,14 @@ def test_deletes_dir_with_readonly_files(self, tmp_path):
107102

108103
assertnottd.exists()
109104

105+
@pytest.mark.skipif(
106+
sys.platform=="cygwin",
107+
reason="Cygwin can't set the permissions that make the test meaningful.",
108+
)
109+
@pytest.mark.skipif(
110+
sys.version_info< (3,8),
111+
reason="In 3.7, TemporaryDirectory doesn't clean up after weird permissions.",
112+
)
110113
deftest_wraps_perm_error_if_enabled(self,mocker,permission_error_tmpdir):
111114
"""rmtree wraps PermissionError when HIDE_WINDOWS_KNOWN_ERRORS is true."""
112115
# Access the module through sys.modules so it is unambiguous which module's
@@ -122,6 +125,14 @@ def test_wraps_perm_error_if_enabled(self, mocker, permission_error_tmpdir):
122125
withpytest.raises(SkipTest):
123126
rmtree(permission_error_tmpdir)
124127

128+
@pytest.mark.skipif(
129+
sys.platform=="cygwin",
130+
reason="Cygwin can't set the permissions that make the test meaningful.",
131+
)
132+
@pytest.mark.skipif(
133+
sys.version_info< (3,8),
134+
reason="In 3.7, TemporaryDirectory doesn't clean up after weird permissions.",
135+
)
125136
deftest_does_not_wrap_perm_error_unless_enabled(self,mocker,permission_error_tmpdir):
126137
"""rmtree does not wrap PermissionError when HIDE_WINDOWS_KNOWN_ERRORS is false."""
127138
# See comments in test_wraps_perm_error_if_enabled for details about patching.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp