From 0ddd74260c5bf429c798a3d03cbf700cb7f35326 Mon Sep 17 00:00:00 2001 From: Justin Salamon Date: Thu, 5 Oct 2017 15:37:40 -0400 Subject: [PATCH] Add test to test_close_temp_files using delete=False --- tests/test_util.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/test_util.py b/tests/test_util.py index c4b063a..c2508c2 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -46,8 +46,8 @@ def test_close_temp_files(): deleted. ''' + # With delete=True tmpfiles = [] - with _close_temp_files(tmpfiles): for _ in range(5): tmpfiles.append( @@ -57,6 +57,17 @@ def test_close_temp_files(): assert tf.file.closed assert not os.path.isfile(tf.name) + # With delete=False + tmpfiles = [] + with _close_temp_files(tmpfiles): + for _ in range(5): + tmpfiles.append( + tempfile.NamedTemporaryFile(suffix='.wav', delete=False)) + + for tf in tmpfiles: + assert tf.file.closed + assert not os.path.isfile(tf.name) + def test_set_temp_logging_level(): '''