Skip to content

Commit ea64bff

Browse files
committed
Avoid leaving un-cleanable temporary directories
1 parent 1c6086a commit ea64bff

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

hypothesis-python/tests/cover/test_database_backend.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -471,14 +471,19 @@ def test_database_directory_inaccessible(dirs, tmp_path, monkeypatch):
471471
monkeypatch.setattr(
472472
configuration, "__hypothesis_home_directory", tmp_path.joinpath(*dirs)
473473
)
474-
tmp_path.chmod(0o000)
475-
with (
476-
nullcontext()
477-
if WINDOWS
478-
else pytest.warns(HypothesisWarning, match=".*the default location is unusable")
479-
):
480-
database = _db_for_path(not_set)
481-
database.save(b"fizz", b"buzz")
474+
try:
475+
tmp_path.chmod(0o000)
476+
with (
477+
nullcontext()
478+
if WINDOWS
479+
else pytest.warns(
480+
HypothesisWarning, match=".*the default location is unusable"
481+
)
482+
):
483+
database = _db_for_path(not_set)
484+
database.save(b"fizz", b"buzz")
485+
finally:
486+
tmp_path.chmod(0o600) # So that pytest can clean up tmp_path later
482487

483488

484489
@skipif_emscripten

0 commit comments

Comments
 (0)