From 71bdb7f6970ab42cc0997ff27f2088b93c126b84 Mon Sep 17 00:00:00 2001 From: Khrystian Clark Date: Wed, 5 Jun 2024 11:24:42 -0700 Subject: [PATCH 1/9] Update test_art.py tmp cleanup Added cleanup function to address the creation of unnecessary tmp files during testing --- test/plugins/test_art.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/test/plugins/test_art.py b/test/plugins/test_art.py index 30f08d50f0..03fc420dae 100644 --- a/test/plugins/test_art.py +++ b/test/plugins/test_art.py @@ -33,7 +33,18 @@ logger = logging.getLogger("beets.test_art") - +def cleanup_tmp_files(): + # List all files and directories in /tmp that start with 'tmp' + temp_files = [f for f in os.listdir('/tmp') if f.startswith('tmp')] + + # Remove each file or directory + for f in temp_files: + temp_path = os.path.join('/tmp', f) + if os.path.isdir(temp_path): + shutil.rmtree(temp_path) + else: + os.remove(temp_path) + class Settings: """Used to pass settings to the ArtSources when the plugin isn't fully instantiated. @@ -1022,3 +1033,6 @@ def suite(): if __name__ == "__main__": unittest.main(defaultTest="suite") + + # Cleanup temporary files + cleanup_tmp_files() From 29a00031a32dec21b2559837f72947861818a6f8 Mon Sep 17 00:00:00 2001 From: Khrystian Clark Date: Wed, 5 Jun 2024 13:09:46 -0700 Subject: [PATCH 2/9] Update test_art.py tmp file cleanup Add cleanup function to test files to remove temporary files --- test/plugins/test_art.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/test/plugins/test_art.py b/test/plugins/test_art.py index 03fc420dae..c630c0780f 100644 --- a/test/plugins/test_art.py +++ b/test/plugins/test_art.py @@ -33,17 +33,6 @@ logger = logging.getLogger("beets.test_art") -def cleanup_tmp_files(): - # List all files and directories in /tmp that start with 'tmp' - temp_files = [f for f in os.listdir('/tmp') if f.startswith('tmp')] - - # Remove each file or directory - for f in temp_files: - temp_path = os.path.join('/tmp', f) - if os.path.isdir(temp_path): - shutil.rmtree(temp_path) - else: - os.remove(temp_path) class Settings: """Used to pass settings to the ArtSources when the plugin isn't fully @@ -1030,6 +1019,18 @@ def test_percent(self): def suite(): return unittest.TestLoader().loadTestsFromName(__name__) +def cleanup_tmp_files(): + # List all files and directories in /tmp that start with 'tmp' + temp_files = [f for f in os.listdir('/tmp') if f.startswith('tmp')] + + # Remove each file or directory + for f in temp_files: + temp_path = os.path.join('/tmp', f) + if os.path.isdir(temp_path): + shutil.rmtree(temp_path) + else: + os.remove(temp_path) + if __name__ == "__main__": unittest.main(defaultTest="suite") From ffb6b03e4a11c21322f0dd8beb05fc98672f0168 Mon Sep 17 00:00:00 2001 From: Khrystian Clark Date: Wed, 5 Jun 2024 13:11:10 -0700 Subject: [PATCH 3/9] Update test_bareasc.py tmp file cleanup Add cleanup function to test files to remove temporary files --- test/plugins/test_bareasc.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/plugins/test_bareasc.py b/test/plugins/test_bareasc.py index 66d8495e56..0c4879f47c 100644 --- a/test/plugins/test_bareasc.py +++ b/test/plugins/test_bareasc.py @@ -87,6 +87,21 @@ def suite(): """loader.""" return unittest.TestLoader().loadTestsFromName(__name__) +def cleanup_tmp_files(): + # List all files and directories in /tmp that start with 'tmp' + temp_files = [f for f in os.listdir('/tmp') if f.startswith('tmp')] + + # Remove each file or directory + for f in temp_files: + temp_path = os.path.join('/tmp', f) + if os.path.isdir(temp_path): + shutil.rmtree(temp_path) + else: + os.remove(temp_path) + if __name__ == "__main__": unittest.main(defaultTest="suite") + + # Cleanup temporary files + cleanup_tmp_files() From 7e3c77308e09df5419c04a1a2148b92c67b96b1e Mon Sep 17 00:00:00 2001 From: Khrystian Clark Date: Wed, 5 Jun 2024 13:12:21 -0700 Subject: [PATCH 4/9] Update test_embedart.py tmp file cleanup Add cleanup function to test files to remove temporary files --- test/plugins/test_embedart.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/plugins/test_embedart.py b/test/plugins/test_embedart.py index 80d284d317..f775307a87 100644 --- a/test/plugins/test_embedart.py +++ b/test/plugins/test_embedart.py @@ -350,6 +350,21 @@ def test_convert_failure(self, mock_extract, mock_subprocess): def suite(): return unittest.TestLoader().loadTestsFromName(__name__) +def cleanup_tmp_files(): + # List all files and directories in /tmp that start with 'tmp' + temp_files = [f for f in os.listdir('/tmp') if f.startswith('tmp')] + + # Remove each file or directory + for f in temp_files: + temp_path = os.path.join('/tmp', f) + if os.path.isdir(temp_path): + shutil.rmtree(temp_path) + else: + os.remove(temp_path) + if __name__ == "__main__": unittest.main(defaultTest="suite") + + # Cleanup temporary files + cleanup_tmp_files() From 61ba5abe74c10bc89257b2c73a993ebd87bc03db Mon Sep 17 00:00:00 2001 From: Khrystian Clark Date: Wed, 5 Jun 2024 13:13:56 -0700 Subject: [PATCH 5/9] Update test_play.py tmp file cleanup Add cleanup function to test files to remove temporary files --- test/plugins/test_play.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/plugins/test_play.py b/test/plugins/test_play.py index cb99f6b433..663c501bd9 100644 --- a/test/plugins/test_play.py +++ b/test/plugins/test_play.py @@ -147,6 +147,22 @@ def test_command_failed(self, open_mock): def suite(): return unittest.TestLoader().loadTestsFromName(__name__) +def cleanup_tmp_files(): + # List all files and directories in /tmp that start with 'tmp' + temp_files = [f for f in os.listdir('/tmp') if f.startswith('tmp')] + + # Remove each file or directory + for f in temp_files: + temp_path = os.path.join('/tmp', f) + if os.path.isdir(temp_path): + shutil.rmtree(temp_path) + else: + os.remove(temp_path) + if __name__ == "__main__": unittest.main(defaultTest="suite") + + # Cleanup temporary files + cleanup_tmp_files() + From a42b5a4a3941dd5fc8a71b903194ce26d4946d54 Mon Sep 17 00:00:00 2001 From: Khrystian Clark Date: Wed, 5 Jun 2024 13:15:50 -0700 Subject: [PATCH 6/9] Update test_zero.py tmp file cleanup Add cleanup function to test files to remove temporary files --- test/plugins/test_zero.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/plugins/test_zero.py b/test/plugins/test_zero.py index 378e419d50..3ed605e28e 100644 --- a/test/plugins/test_zero.py +++ b/test/plugins/test_zero.py @@ -1,5 +1,7 @@ """Tests for the 'zero' plugin""" +import os +import shutil import unittest from mediafile import MediaFile @@ -297,6 +299,22 @@ def test_empty_query_n_response_no_changes(self): def suite(): return unittest.TestLoader().loadTestsFromName(__name__) +def cleanup_tmp_files(): + # List all files and directories in /tmp that start with 'tmp' + temp_files = [f for f in os.listdir('/tmp') if f.startswith('tmp')] + + # Remove each file or directory + for f in temp_files: + temp_path = os.path.join('/tmp', f) + if os.path.isdir(temp_path): + shutil.rmtree(temp_path) + else: + os.remove(temp_path) + if __name__ == "__main__": unittest.main(defaultTest="suite") + + # Cleanup temporary files + cleanup_tmp_files() + From b0c9a139ae197994927d27e89c3a7ac532cf2bb6 Mon Sep 17 00:00:00 2001 From: Khrystian Clark Date: Wed, 5 Jun 2024 13:16:45 -0700 Subject: [PATCH 7/9] Update test_play.py --- test/plugins/test_play.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test/plugins/test_play.py b/test/plugins/test_play.py index 663c501bd9..975e148ccc 100644 --- a/test/plugins/test_play.py +++ b/test/plugins/test_play.py @@ -16,6 +16,7 @@ import os +import shutil import sys import unittest from unittest.mock import ANY, patch From 40176908bb57f94c70a1a22e7ae650af65a666d9 Mon Sep 17 00:00:00 2001 From: Khrystian Clark Date: Wed, 5 Jun 2024 13:17:23 -0700 Subject: [PATCH 8/9] Update test_embedart.py --- test/plugins/test_embedart.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test/plugins/test_embedart.py b/test/plugins/test_embedart.py index f775307a87..2b24fa7c0e 100644 --- a/test/plugins/test_embedart.py +++ b/test/plugins/test_embedart.py @@ -14,6 +14,7 @@ import os.path +import os import shutil import tempfile import unittest From f4070e60509926007c578cd962ed1837f86bcf15 Mon Sep 17 00:00:00 2001 From: Khrystian Clark Date: Wed, 5 Jun 2024 13:18:00 -0700 Subject: [PATCH 9/9] Update test_bareasc.py --- test/plugins/test_bareasc.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/plugins/test_bareasc.py b/test/plugins/test_bareasc.py index 0c4879f47c..5ea815969a 100644 --- a/test/plugins/test_bareasc.py +++ b/test/plugins/test_bareasc.py @@ -3,6 +3,8 @@ """Tests for the 'bareasc' plugin.""" +import os +import shutil import unittest from beets import logging