From 799b0fb5c64abd6daa2887ddd7816a7ec51c343c Mon Sep 17 00:00:00 2001 From: Axel Dahlberg Date: Sun, 17 Jan 2021 14:36:26 +0100 Subject: Test when cleanup_file context fails --- tests/unit/utils/test_utils.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests/unit/utils') diff --git a/tests/unit/utils/test_utils.py b/tests/unit/utils/test_utils.py index 74b49f573..238e89736 100644 --- a/tests/unit/utils/test_utils.py +++ b/tests/unit/utils/test_utils.py @@ -904,3 +904,10 @@ class TestCleanupFileContext: with utils.cleanup_file(tmpfile): raise RuntimeError assert not tmpfile.exists() + + def test_directory(self, tmp_path, caplog): + assert tmp_path.is_dir() + # removal of file fails since it's a directory + with caplog.at_level(logging.ERROR, 'misc'): + with utils.cleanup_file(tmp_path): + pass -- cgit v1.2.3-54-g00ecf