-
-
Notifications
You must be signed in to change notification settings - Fork 954
Reorganize test_util and make xfail marks precise #1729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
09826f4
e2fa5e2
c4da058
aa1799f
2fb8c64
1dccb8e
487bc8a
c3d3d1e
7d98f94
ba5bc45
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
This moves test skipping logic from the permission_error_tmpdir fixture to the two TestRmtree test case methods that use it. This produces some duplication, which is undesirable, but it makes it so that which tests are skipped under what conditions is immediately clear, easy to identify as skipping logic (which is usually achieved by decoration), and clear in its relationship to the skipping logic associated with other TestRmtree test cases.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,11 +46,6 @@ | |
@pytest.fixture | ||
def permission_error_tmpdir(tmp_path): | ||
"""Fixture to test permissions errors situations where they are not overcome.""" | ||
if sys.platform == "cygwin": | ||
raise SkipTest("Cygwin can't set the permissions that make the test meaningful.") | ||
if sys.version_info < (3, 8): | ||
raise SkipTest("In 3.7, TemporaryDirectory doesn't clean up after weird permissions.") | ||
|
||
td = tmp_path / "testdir" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I keep choking on this as it seems more fragile than it has to be given that one could also create a tempdir with a unique name as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you tell me more about this concern? I'll be working on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, perfect, then there is no concern, I just wasn't aware and too overwhelmed/not very focussed at the time. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Ah, excellent. Some of the code this PR modifies are the tests I introduced it in #1700. Both before and after the changes here, these tests may give the mistaken impression that variables like After all, if I do this for several reasons:
This may be insufficiently clear in reading the test code, and if so, I would be interested in improving the situation, perhaps by changing some variable names, adding/expanding some docstrings or comments, or both. But maybe that wouldn't help; I'm not sure. (Edit: Regarding the broader issue of test-runner parallelism, I've posted a separate top-level comment below.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the explanation! Personally I think that it's OK to leave it as is but refactor the next time one stumbles over it. Please note that I didn't read the top-level comment yet, to which I will probably reply separately. |
||
td.mkdir() | ||
(td / "x").write_bytes(b"") | ||
|
@@ -107,6 +102,14 @@ def test_deletes_dir_with_readonly_files(self, tmp_path): | |
|
||
assert not td.exists() | ||
|
||
@pytest.mark.skipif( | ||
sys.platform == "cygwin", | ||
reason="Cygwin can't set the permissions that make the test meaningful.", | ||
) | ||
@pytest.mark.skipif( | ||
sys.version_info < (3, 8), | ||
reason="In 3.7, TemporaryDirectory doesn't clean up after weird permissions.", | ||
) | ||
def test_wraps_perm_error_if_enabled(self, mocker, permission_error_tmpdir): | ||
"""rmtree wraps PermissionError when HIDE_WINDOWS_KNOWN_ERRORS is true.""" | ||
# 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): | |
with pytest.raises(SkipTest): | ||
rmtree(permission_error_tmpdir) | ||
|
||
@pytest.mark.skipif( | ||
sys.platform == "cygwin", | ||
reason="Cygwin can't set the permissions that make the test meaningful.", | ||
) | ||
@pytest.mark.skipif( | ||
sys.version_info < (3, 8), | ||
reason="In 3.7, TemporaryDirectory doesn't clean up after weird permissions.", | ||
) | ||
def test_does_not_wrap_perm_error_unless_enabled(self, mocker, permission_error_tmpdir): | ||
"""rmtree does not wrap PermissionError when HIDE_WINDOWS_KNOWN_ERRORS is false.""" | ||
# See comments in test_wraps_perm_error_if_enabled for details about patching. | ||
|