Skip to content

Commit

Permalink
add test for construct mode
Browse files Browse the repository at this point in the history
  • Loading branch information
stephprince committed Nov 7, 2024
1 parent e4605bd commit 30dca97
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/hdmf/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def __new__(cls, *args, **kwargs):
def __init__(self, **kwargs):
name = getargs('name', kwargs)
if ('/' in name or ':' in name) and not self._in_construct_mode:
raise ValueError(f"name '{name}' cannot contain '/' or ':'")
raise ValueError(f"name '{name}' cannot contain a '/' or ':'")
self.__name = name
self.__field_values = dict()
self.__read_io = None
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/test_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,17 @@ def test_set_parent_overwrite_proxy(self):
def test_slash_restriction(self):
self.assertRaises(ValueError, Container, 'bad/name')

# check no error raised in construct mode
child_obj = Container.__new__(Container, parent=None, object_id=None, in_construct_mode=True)
child_obj.__init__('bad/name')

def test_colon_restriction(self):
self.assertRaises(ValueError, Container, 'bad:name')

# check no error raised in construct mode
child_obj = Container.__new__(Container, parent=None, object_id=None, in_construct_mode=True)
child_obj.__init__('bad:name')

def test_set_modified_parent(self):
"""Test that set modified properly sets parent modified
"""
Expand Down

0 comments on commit 30dca97

Please sign in to comment.