MCPcopy Create free account
hub / github.com/PyTables/PyTables / test_openFileA

Method test_openFileA

tables/tests/test_create.py:1786–1840  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1784 self.assertEqual(root.table.cols.var1.dtype, tb.IntCol().dtype)
1785
1786 def test_openFileA(self):
1787 self.h5file.close()
1788 self.h5file = None
1789
1790 self.assertIsFile()
1791
1792 # Open an existing HDF5 file in append mode
1793 self.h5file = tb.open_file(
1794 self.h5fname, mode="a", driver=self.DRIVER, **self.DRIVER_PARAMS
1795 )
1796
1797 # check contents
1798 root = self.h5file.root
1799
1800 self.assertEqual(self.h5file.get_node_attr(root, "testattr"), 41)
1801
1802 self.assertIsInstance(root.array, tb.Array)
1803 self.assertEqual(root.array._v_title, "array")
1804
1805 self.assertIsInstance(root.table, tb.Table)
1806 self.assertEqual(root.table._v_title, "table")
1807 self.assertIn("var1", root.table.colnames)
1808 self.assertEqual(root.table.cols.var1.dtype, tb.IntCol().dtype)
1809
1810 # write new data
1811 root = self.h5file.root
1812 self.h5file.set_node_attr(root, "testattr2", 42)
1813 self.h5file.create_array(root, "array2", [1, 2], title="array2")
1814 self.h5file.create_table(
1815 root, "table2", {"var2": tb.FloatCol()}, title="table2"
1816 )
1817
1818 # check contents
1819 self._reopen(mode="a", driver=self.DRIVER, **self.DRIVER_PARAMS)
1820
1821 root = self.h5file.root
1822
1823 self.assertEqual(self.h5file.get_node_attr(root, "testattr"), 41)
1824 self.assertEqual(self.h5file.get_node_attr(root, "testattr2"), 42)
1825
1826 self.assertIsInstance(root.array, tb.Array)
1827 self.assertEqual(root.array._v_title, "array")
1828
1829 self.assertIsInstance(root.array2, tb.Array)
1830 self.assertEqual(root.array2._v_title, "array2")
1831
1832 self.assertIsInstance(root.table, tb.Table)
1833 self.assertEqual(root.table._v_title, "table")
1834 self.assertIn("var1", root.table.colnames)
1835 self.assertEqual(root.table.cols.var1.dtype, tb.IntCol().dtype)
1836
1837 self.assertIsInstance(root.table2, tb.Table)
1838 self.assertEqual(root.table2._v_title, "table2")
1839 self.assertIn("var2", root.table2.colnames)
1840 self.assertEqual(root.table2.cols.var2.dtype, tb.FloatCol().dtype)
1841
1842 def test_openFileRW(self):
1843 self.h5file.close()

Callers

nothing calls this directly

Calls 7

assertIsFileMethod · 0.95
get_node_attrMethod · 0.80
set_node_attrMethod · 0.80
closeMethod · 0.45
create_arrayMethod · 0.45
create_tableMethod · 0.45
_reopenMethod · 0.45

Tested by

no test coverage detected