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

Method test01_copy

tables/tests/test_create.py:1282–1357  ·  view source on GitHub ↗

Checking copy of a File (attributes not copied)

(self)

Source from the content-addressed store, hash-verified

1280 self.assertEqual(self.h5file2.title, self.title)
1281
1282 def test01_copy(self):
1283 """Checking copy of a File (attributes not copied)"""
1284
1285 if common.verbose:
1286 print("\n", "-=" * 30)
1287 print("Running %s.test01_copy..." % self.__class__.__name__)
1288
1289 # Copy the file to the destination
1290 self.h5file.copy_file(
1291 self.h5fname2,
1292 title=self.title,
1293 copyuserattrs=0,
1294 filters=self.filters,
1295 )
1296
1297 # Close the original file, if needed
1298 if self.close:
1299 self._reopen()
1300
1301 # ...and open the destination file
1302 self.h5file2 = tb.open_file(self.h5fname2, "r")
1303
1304 # Check that the copy has been done correctly
1305 srcgroup = self.h5file.root
1306 dstgroup = self.h5file2.root
1307 nodelist1 = list(srcgroup._v_children)
1308 nodelist2 = list(dstgroup._v_children)
1309
1310 # Sort the lists
1311 nodelist1.sort()
1312 nodelist2.sort()
1313 if common.verbose:
1314 print("The origin node list -->", nodelist1)
1315 print("The copied node list -->", nodelist2)
1316 self.assertEqual(srcgroup._v_nchildren, dstgroup._v_nchildren)
1317 self.assertEqual(nodelist1, nodelist2)
1318 # print("_v_attrnames-->", self.h5file2.root._v_attrs._v_attrnames)
1319 # print("--> <%s,%s>" % (self.h5file2.title, self.title))
1320 self.assertEqual(self.h5file2.title, self.title)
1321
1322 # Check that user attributes has not been copied
1323 for srcnode in srcgroup:
1324 dstnode = getattr(dstgroup, srcnode._v_name)
1325 srcattrs = srcnode._v_attrs
1326 srcattrskeys = srcattrs._f_list("sys")
1327 dstattrs = dstnode._v_attrs
1328 dstattrskeys = dstattrs._f_list("all")
1329
1330 # Filters may differ, do not take into account
1331 if self.filters is not None:
1332 dstattrskeys.remove("FILTERS")
1333
1334 # These lists should already be ordered
1335 if common.verbose:
1336 print(
1337 f"srcattrskeys for node {srcnode._v_name}: "
1338 f"{srcattrskeys}"
1339 )

Callers

nothing calls this directly

Calls 4

copy_fileMethod · 0.80
_f_listMethod · 0.80
_reopenMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected