From d9cd81debd351999eac3dbed3609ac7eab11fb3f Mon Sep 17 00:00:00 2001 From: Tim Jenness Date: Wed, 3 Jan 2024 11:48:30 -0700 Subject: [PATCH] Modify directory cleanup to avoid ResourceWarning Deleting the variable does trigger the clean up of the temporary directory but it also issues a warning: ResourceWarning: Implicitly cleaning up Replace the tearDown with an explicit cleanup() call. Also ensure that any errors in clean up do not cause the tests to fail. --- tests/test_calibrateImage.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_calibrateImage.py b/tests/test_calibrateImage.py index a4db76eba..ed6d4092a 100644 --- a/tests/test_calibrateImage.py +++ b/tests/test_calibrateImage.py @@ -310,7 +310,7 @@ def setUp(self): detector = 42 # Create a and populate a test butler for runQuantum tests. - self.repo_path = tempfile.TemporaryDirectory() + self.repo_path = tempfile.TemporaryDirectory(ignore_cleanup_errors=True) self.repo = butlerTests.makeTestRepo(self.repo_path.name) # dataIds for fake data @@ -366,7 +366,7 @@ def setUp(self): self.butler.put(afwTable.SimpleCatalog(), "ps1_pv3_3pi_20170110", self.htm_id) def tearDown(self): - del self.repo_path # this removes the temporary directory + self.repo_path.cleanup() def test_runQuantum(self): task = CalibrateImageTask()