Skip to content

Commit

Permalink
Merge pull request #12773 from matthewhughes934/fix-tests-unable-to-c…
Browse files Browse the repository at this point in the history
…leanup
  • Loading branch information
uranusjr committed Jun 24, 2024
2 parents 67e2a56 + 8cdf797 commit 00c75c4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Empty file.
11 changes: 7 additions & 4 deletions tests/unit/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,10 @@ def test_rmtree_errorhandler_reraises_error(tmpdir: Path) -> None:
by the given unreadable directory.
"""
# Create directory without read permission
subdir_path = tmpdir / "subdir"
subdir_path.mkdir()
path = str(subdir_path)
os.chmod(path, stat.S_IWRITE)
path = tmpdir / "subdir"
path.mkdir()
old_mode = path.stat().st_mode
path.chmod(stat.S_IWRITE)

mock_func = Mock()

Expand All @@ -267,6 +267,9 @@ def test_rmtree_errorhandler_reraises_error(tmpdir: Path) -> None:
rmtree_errorhandler(
mock_func, path, sys.exc_info() # type: ignore[arg-type]
)
finally:
# Restore permissions to let pytest to clean up temp dirs
path.chmod(old_mode)

mock_func.assert_not_called()

Expand Down

0 comments on commit 00c75c4

Please sign in to comment.