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

Method test00

tables/tests/test_do_undo.py:2247–2299  ·  view source on GitHub ↗

Mix of create_array, create_group, renameNone, move_node, remove_node, copy_node and copy_children.

(self)

Source from the content-addressed store, hash-verified

2245 h5file.create_group(group, "agroup3", "Group title 3")
2246
2247 def test00(self):
2248 """Mix of create_array, create_group, renameNone, move_node,
2249 remove_node, copy_node and copy_children."""
2250
2251 if common.verbose:
2252 print("\n", "-=" * 30)
2253 print("Running %s.test00..." % self.__class__.__name__)
2254
2255 # Enable undo/redo.
2256 self.h5file.enable_undo()
2257
2258 # Create an array
2259 self.h5file.create_array(
2260 self.h5file.root, "anarray3", [1], "Array title 3"
2261 )
2262 # Create a group
2263 self.h5file.create_group(self.h5file.root, "agroup3", "Group title 3")
2264
2265 # /anarray => /agroup/agroup3/
2266 new_node = self.h5file.copy_node("/anarray3", "/agroup/agroup3")
2267 new_node = self.h5file.copy_children(
2268 "/agroup", "/agroup3", recursive=1
2269 )
2270
2271 # rename anarray
2272 self.h5file.rename_node("/anarray", "anarray4")
2273
2274 # Move anarray
2275 new_node = self.h5file.copy_node("/anarray3", "/agroup")
2276
2277 # Remove anarray4
2278 self.h5file.remove_node("/anarray4")
2279
2280 # Undo the actions
2281 self.h5file.undo()
2282 self.assertNotIn("/anarray4", self.h5file)
2283 self.assertNotIn("/anarray3", self.h5file)
2284 self.assertNotIn("/agroup/agroup3/anarray3", self.h5file)
2285 self.assertNotIn("/agroup3", self.h5file)
2286 self.assertNotIn("/anarray4", self.h5file)
2287 self.assertIn("/anarray", self.h5file)
2288
2289 # Redo the actions
2290 self.h5file.redo()
2291
2292 # Check that the copied node exists again in the object tree.
2293 self.assertIn("/agroup/agroup3/anarray3", self.h5file)
2294 self.assertIn("/agroup/anarray3", self.h5file)
2295 self.assertIn("/agroup3/agroup3/anarray3", self.h5file)
2296 self.assertNotIn("/agroup3/anarray3", self.h5file)
2297 self.assertIs(self.h5file.root.agroup.anarray3, new_node)
2298 self.assertNotIn("/anarray", self.h5file)
2299 self.assertNotIn("/anarray4", self.h5file)
2300
2301 def test01(self):
2302 """Test with multiple generations (Leaf case)"""

Callers

nothing calls this directly

Calls 9

enable_undoMethod · 0.80
create_groupMethod · 0.80
copy_nodeMethod · 0.80
remove_nodeMethod · 0.80
undoMethod · 0.80
redoMethod · 0.80
create_arrayMethod · 0.45
copy_childrenMethod · 0.45
rename_nodeMethod · 0.45

Tested by

no test coverage detected