Skip to content

Commit 35377c9

Browse files
committed
Add test for tempdir registry lazy eval
1 parent ffa6d9d commit 35377c9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/unit/test_utils_temp_dir.py

+14
Original file line numberDiff line numberDiff line change
@@ -234,3 +234,17 @@ def test_tempdir_registry(kind, delete, exists):
234234
path = d.path
235235
assert os.path.exists(path)
236236
assert os.path.exists(path) == exists
237+
238+
239+
@pytest.mark.parametrize("should_delete", [True, False])
240+
def test_tempdir_registry_lazy(should_delete):
241+
"""
242+
Test the registry entry can be updated after a temp dir is created,
243+
to change whether a kind should be deleted or not.
244+
"""
245+
with tempdir_registry() as registry:
246+
with TempDirectory(delete=None, kind="test-for-lazy") as d:
247+
path = d.path
248+
registry.set_delete("test-for-lazy", should_delete)
249+
assert os.path.exists(path)
250+
assert os.path.exists(path) == (not should_delete)

0 commit comments

Comments
 (0)