Skip to content

Commit

Permalink
Modify directory cleanup to avoid ResourceWarning
Browse files Browse the repository at this point in the history
Deleting the variable does trigger the clean up of the temporary
directory but it also issues a warning:

ResourceWarning: Implicitly cleaning up <TemporaryDirectory '/var/folders/1x/h9lknjv97cx6lw9npp95xkyr0000gn/T/tmpav1qw4d_'>

Replace the tearDown with an explicit cleanup() call. Also ensure
that any errors in clean up do not cause the tests to fail.
  • Loading branch information
timj committed Jan 4, 2024
1 parent e6dbd61 commit d9cd81d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests/test_calibrateImage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit d9cd81d

Please sign in to comment.