Skip to content

Commit

Permalink
Add test for tempdir registry lazy eval
Browse files Browse the repository at this point in the history
  • Loading branch information
uranusjr committed Jan 19, 2020
1 parent ffa6d9d commit 35377c9
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/unit/test_utils_temp_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,3 +234,17 @@ def test_tempdir_registry(kind, delete, exists):
path = d.path
assert os.path.exists(path)
assert os.path.exists(path) == exists


@pytest.mark.parametrize("should_delete", [True, False])
def test_tempdir_registry_lazy(should_delete):
"""
Test the registry entry can be updated after a temp dir is created,
to change whether a kind should be deleted or not.
"""
with tempdir_registry() as registry:
with TempDirectory(delete=None, kind="test-for-lazy") as d:
path = d.path
registry.set_delete("test-for-lazy", should_delete)
assert os.path.exists(path)
assert os.path.exists(path) == (not should_delete)

0 comments on commit 35377c9

Please sign in to comment.