Skip to content

Commit 06ee477

Browse files
authored
Fix pytest UnraisableExceptionWarning (#916)
1 parent ff30e12 commit 06ee477

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

requirements.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# pinned dependencies to reproduce an entire development environment to use HDMF
2-
h5py==3.8.0
3-
importlib-resources==5.12.0; python_version < "3.9" # TODO: remove when when minimum python version is 3.9
4-
jsonschema==4.17.3
5-
numpy==1.24.3
6-
pandas==2.0.1
7-
ruamel.yaml==0.17.24
8-
scipy==1.10.1
2+
h5py==3.9.0
3+
importlib-resources==6.0.0; python_version < "3.9" # TODO: remove when minimum python version is 3.9
4+
jsonschema==4.18.4
5+
numpy==1.25.1
6+
pandas==2.0.3
7+
ruamel.yaml==0.17.32
8+
scipy==1.11.1

src/hdmf/container.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,11 @@ def __gather_fields(cls, name, bases, classdict):
194194

195195
def __del__(self):
196196
# Make sure the reference counter for our read IO is being decremented
197-
del self.__read_io
198-
self.__read_io = None
197+
try:
198+
del self.__read_io
199+
self.__read_io = None
200+
except AttributeError:
201+
pass
199202

200203
def __new__(cls, *args, **kwargs):
201204
"""

tests/unit/test_container.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,13 @@ def test_get_read_io_on_parent(self):
131131
self.assertIsNone(child_obj.read_io)
132132
self.assertIs(child_obj.get_read_io(), temp_io)
133133

134+
def test_del_read_io(self):
135+
class TestContainer(AbstractContainer):
136+
def __init__(self):
137+
raise ValueError("Error")
138+
with self.assertRaises(ValueError):
139+
TestContainer()
140+
134141
def test_set_parent(self):
135142
"""Test that parent setter properly sets parent
136143
"""

0 commit comments

Comments
 (0)