From abf935b2c9ba1e7937c121c9e32f868c1c020fd7 Mon Sep 17 00:00:00 2001 From: Yusuke Kadowaki Date: Thu, 27 Oct 2022 01:17:34 +0900 Subject: [PATCH] Add test for retention count == 0 --- testing/test_tmpdir.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/testing/test_tmpdir.py b/testing/test_tmpdir.py index 29eaf3c33..7a081287f 100644 --- a/testing/test_tmpdir.py +++ b/testing/test_tmpdir.py @@ -277,12 +277,12 @@ class TestNumberedDir: assert not lock.exists() - def _do_cleanup(self, tmp_path: Path) -> None: + def _do_cleanup(self, tmp_path: Path, keep: int = 2) -> None: self.test_make(tmp_path) cleanup_numbered_dir( root=tmp_path, prefix=self.PREFIX, - keep=2, + keep=keep, consider_lock_dead_if_created_before=0, ) @@ -291,6 +291,11 @@ class TestNumberedDir: a, b = (x for x in tmp_path.iterdir() if not x.is_symlink()) print(a, b) + def test_cleanup_keep_0(self, tmp_path: Path): + self._do_cleanup(tmp_path, 0) + dir_num = len(list(tmp_path.iterdir())) + assert dir_num == 0 + def test_cleanup_locked(self, tmp_path): p = make_numbered_dir(root=tmp_path, prefix=self.PREFIX)