(self)
| 1840 | self.assertEqual(root.table2.cols.var2.dtype, tb.FloatCol().dtype) |
| 1841 | |
| 1842 | def test_openFileRW(self): |
| 1843 | self.h5file.close() |
| 1844 | self.h5file = None |
| 1845 | |
| 1846 | self.assertIsFile() |
| 1847 | |
| 1848 | # Open an existing HDF5 file in append mode |
| 1849 | self.h5file = tb.open_file( |
| 1850 | self.h5fname, mode="r+", driver=self.DRIVER, **self.DRIVER_PARAMS |
| 1851 | ) |
| 1852 | |
| 1853 | # check contents |
| 1854 | root = self.h5file.root |
| 1855 | |
| 1856 | self.assertEqual(self.h5file.get_node_attr(root, "testattr"), 41) |
| 1857 | |
| 1858 | self.assertIsInstance(root.array, tb.Array) |
| 1859 | self.assertEqual(root.array._v_title, "array") |
| 1860 | |
| 1861 | self.assertIsInstance(root.table, tb.Table) |
| 1862 | self.assertEqual(root.table._v_title, "table") |
| 1863 | self.assertIn("var1", root.table.colnames) |
| 1864 | self.assertEqual(root.table.cols.var1.dtype, tb.IntCol().dtype) |
| 1865 | |
| 1866 | # write new data |
| 1867 | self.h5file.set_node_attr(root, "testattr2", 42) |
| 1868 | self.h5file.create_array(root, "array2", [1, 2], title="array2") |
| 1869 | self.h5file.create_table( |
| 1870 | root, "table2", {"var2": tb.FloatCol()}, title="table2" |
| 1871 | ) |
| 1872 | |
| 1873 | # check contents |
| 1874 | self._reopen(mode="r+", driver=self.DRIVER, **self.DRIVER_PARAMS) |
| 1875 | |
| 1876 | root = self.h5file.root |
| 1877 | |
| 1878 | self.assertEqual(self.h5file.get_node_attr(root, "testattr"), 41) |
| 1879 | self.assertEqual(self.h5file.get_node_attr(root, "testattr2"), 42) |
| 1880 | |
| 1881 | self.assertIsInstance(root.array, tb.Array) |
| 1882 | self.assertEqual(root.array._v_title, "array") |
| 1883 | |
| 1884 | self.assertIsInstance(root.array2, tb.Array) |
| 1885 | self.assertEqual(root.array2._v_title, "array2") |
| 1886 | |
| 1887 | self.assertIsInstance(root.table, tb.Table) |
| 1888 | self.assertEqual(root.table._v_title, "table") |
| 1889 | self.assertIn("var1", root.table.colnames) |
| 1890 | self.assertEqual(root.table.cols.var1.dtype, tb.IntCol().dtype) |
| 1891 | |
| 1892 | self.assertIsInstance(root.table2, tb.Table) |
| 1893 | self.assertEqual(root.table2._v_title, "table2") |
| 1894 | self.assertIn("var2", root.table2.colnames) |
| 1895 | self.assertEqual(root.table2.cols.var2.dtype, tb.FloatCol().dtype) |
| 1896 | |
| 1897 | |
| 1898 | class Sec2DriverTestCase(DefaultDriverTestCase): |
nothing calls this directly
no test coverage detected