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

Function demo_manyops

examples/undo-redo.py:95–135  ·  view source on GitHub ↗

Checking many operations together.

()

Source from the content-addressed store, hash-verified

93
94
95def demo_manyops():
96 """Checking many operations together."""
97
98 # Initialize the data base with some nodes
99 fileh = setUp("undo-redo-manyops.h5")
100
101 # Create an array
102 fileh.create_array(fileh.root, "anarray3", [3], "Array title 3")
103 # Create a group
104 fileh.create_group(fileh.root, "agroup3", "Group title 3")
105 # /anarray => /agroup/agroup3/
106 new_node = fileh.copy_node("/anarray3", "/agroup/agroup2")
107 new_node = fileh.copy_children("/agroup", "/agroup3", recursive=1)
108 # rename anarray
109 fileh.rename_node("/anarray", "anarray4")
110 # Move anarray
111 new_node = fileh.copy_node("/anarray3", "/agroup")
112 # Remove anarray4
113 fileh.remove_node("/anarray4")
114 # Undo the actions
115 fileh.undo()
116 assert "/anarray4" not in fileh
117 assert "/anarray3" not in fileh
118 assert "/agroup/agroup2/anarray3" not in fileh
119 assert "/agroup3" not in fileh
120 assert "/anarray4" not in fileh
121 assert "/anarray" in fileh
122
123 # Redo the actions
124 fileh.redo()
125 # Check that the copied node exists again in the object tree.
126 assert "/agroup/agroup2/anarray3" in fileh
127 assert "/agroup/anarray3" in fileh
128 assert "/agroup3/agroup2/anarray3" in fileh
129 assert "/agroup3/anarray3" not in fileh
130 assert fileh.root.agroup.anarray3 is new_node
131 assert "/anarray" not in fileh
132 assert "/anarray4" not in fileh
133
134 # Tear down the file
135 tearDown(fileh)
136
137
138if __name__ == "__main__":

Callers 1

undo-redo.pyFile · 0.85

Calls 10

setUpFunction · 0.85
tearDownFunction · 0.85
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