Skip to content

Commit

Permalink
Fix table copy (Closes: PyTables#1208)
Browse files Browse the repository at this point in the history
  • Loading branch information
avalentino committed Sep 21, 2024
1 parent e3a0b72 commit 355a8d3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
1 change: 1 addition & 0 deletions tables/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,7 @@ def _get_or_create_path(self, path: Union[Node, str],
"""

if create:
path = path._v_pathname if hasattr(path, "_v_pathname") else path
return self._create_path(path)
else:
return self.get_node(path)
Expand Down
8 changes: 8 additions & 0 deletions tables/tests/test_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -5374,6 +5374,14 @@ def test05b_copy(self):
self.assertEqual(hasattr(table2.attrs, "attr2"), 0)


class CopyIssuesTestCase(common.TempFileMixin, common.PyTablesTestCase):
def test_issue1208(self):
# https://github.com/PyTables/PyTables/issues/1208
group = self.h5file.create_group('this', 'that', createparents=True)
node = self.h5file.create_table('/', 'here', {'a': tb.UInt32Col()})
node.copy(group, createparents=True, overwrite=True)


class CloseCopyTestCase(CopyTestCase):
close = True
aligned = False
Expand Down
14 changes: 0 additions & 14 deletions tables/tests/test_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -1052,20 +1052,6 @@ def setUp(self):
self.h5file.create_array('/', 'array', [1])
self.h5file.create_group('/', 'group', filters=self.filters)

def test00_parentType(self):
"""Using the right type of parent node argument."""

h5file, root = self.h5file, self.h5file.root

self.assertRaises(TypeError, h5file.create_array,
root.group, 'arr', [1], createparents=True)
self.assertRaises(TypeError, h5file.copy_node,
'/array', root.group, createparents=True)
self.assertRaises(TypeError, h5file.move_node,
'/array', root.group, createparents=True)
self.assertRaises(TypeError, h5file.copy_children,
'/group', root, createparents=True)

def test01_inside(self):
"""Placing a node inside a nonexistent child of itself."""
self.assertRaises(tb.NodeError, self.h5file.move_node,
Expand Down

0 comments on commit 355a8d3

Please sign in to comment.