Skip to content

Commit

Permalink
Fix pytest UnraisableExceptionWarning (#916)
Browse files Browse the repository at this point in the history
  • Loading branch information
rly authored Jul 25, 2023
1 parent ff30e12 commit 06ee477
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
14 changes: 7 additions & 7 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# pinned dependencies to reproduce an entire development environment to use HDMF
h5py==3.8.0
importlib-resources==5.12.0; python_version < "3.9" # TODO: remove when when minimum python version is 3.9
jsonschema==4.17.3
numpy==1.24.3
pandas==2.0.1
ruamel.yaml==0.17.24
scipy==1.10.1
h5py==3.9.0
importlib-resources==6.0.0; python_version < "3.9" # TODO: remove when minimum python version is 3.9
jsonschema==4.18.4
numpy==1.25.1
pandas==2.0.3
ruamel.yaml==0.17.32
scipy==1.11.1
7 changes: 5 additions & 2 deletions src/hdmf/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,11 @@ def __gather_fields(cls, name, bases, classdict):

def __del__(self):
# Make sure the reference counter for our read IO is being decremented
del self.__read_io
self.__read_io = None
try:
del self.__read_io
self.__read_io = None
except AttributeError:
pass

def __new__(cls, *args, **kwargs):
"""
Expand Down
7 changes: 7 additions & 0 deletions tests/unit/test_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ def test_get_read_io_on_parent(self):
self.assertIsNone(child_obj.read_io)
self.assertIs(child_obj.get_read_io(), temp_io)

def test_del_read_io(self):
class TestContainer(AbstractContainer):
def __init__(self):
raise ValueError("Error")
with self.assertRaises(ValueError):
TestContainer()

def test_set_parent(self):
"""Test that parent setter properly sets parent
"""
Expand Down

0 comments on commit 06ee477

Please sign in to comment.