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

Method test00_overwrite

tables/tests/test_create.py:1189–1228  ·  view source on GitHub ↗

Checking copy of a File (overwriting file)

(self)

Source from the content-addressed store, hash-verified

1187 super().tearDown()
1188
1189 def test00_overwrite(self):
1190 """Checking copy of a File (overwriting file)"""
1191
1192 if common.verbose:
1193 print("\n", "-=" * 30)
1194 print("Running %s.test00_overwrite..." % self.__class__.__name__)
1195
1196 # Create a temporary file
1197 Path(self.h5fname2).write_text("")
1198
1199 # Copy the file to the destination
1200 self.h5file.copy_file(
1201 self.h5fname2,
1202 title=self.title,
1203 overwrite=1,
1204 copyuserattrs=0,
1205 filters=None,
1206 )
1207
1208 # Close the original file, if needed
1209 if self.close:
1210 self._reopen()
1211
1212 # ...and open the destination file
1213 self.h5file2 = tb.open_file(self.h5fname2, "r")
1214
1215 # Check that the copy has been done correctly
1216 srcgroup = self.h5file.root
1217 dstgroup = self.h5file2.root
1218 nodelist1 = list(srcgroup._v_children)
1219 nodelist2 = list(dstgroup._v_children)
1220 # Sort the lists
1221 nodelist1.sort()
1222 nodelist2.sort()
1223 if common.verbose:
1224 print("The origin node list -->", nodelist1)
1225 print("The copied node list -->", nodelist2)
1226 self.assertEqual(srcgroup._v_nchildren, dstgroup._v_nchildren)
1227 self.assertEqual(nodelist1, nodelist2)
1228 self.assertEqual(self.h5file2.title, self.title)
1229
1230 def test00a_srcdstequal(self):
1231 """Checking copy of a File (srcfile == dstfile)"""

Callers

nothing calls this directly

Calls 2

copy_fileMethod · 0.80
_reopenMethod · 0.45

Tested by

no test coverage detected