Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove __del__ from DataModel. #286

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/roman_datamodels/datamodels/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,6 @@ def __enter__(self):
def __exit__(self, exc_type, exc_val, exc_tb):
self.close()

def __del__(self):
"""Ensure closure of resources when deleted."""
self.close()

def copy(self, deepcopy=True, memo=None):
result = self.__class__(init=None)
self.clone(result, self, deepcopy=deepcopy, memo=memo)
Expand Down
14 changes: 8 additions & 6 deletions tests/test_stnode.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,17 +278,19 @@ def test_nuke_validation(nuke_env_var, tmp_path):

# Read broken files with datamodel object
with context:
datamodels.WfiImgPhotomRefModel(broken_save)
dm = datamodels.WfiImgPhotomRefModel(broken_save)
dm.close()
with context:
datamodels.WfiImgPhotomRefModel(broken_to_asdf)
dm = datamodels.WfiImgPhotomRefModel(broken_to_asdf)
dm.close()

# True to read broken files with rdm.open
with context:
with datamodels.open(broken_save):
pass
with datamodels.open(broken_save) as dm:
dm.close()
with context:
with datamodels.open(broken_to_asdf):
pass
with datamodels.open(broken_to_asdf) as dm:
dm.close()


@pytest.mark.parametrize("nuke_env_strict_var", VALIDATION_CASES, indirect=True)
Expand Down