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

Method test02_listNodes

tables/tests/test_tree.py:205–331  ·  view source on GitHub ↗

Checking the File.list_nodes() method

(self)

Source from the content-addressed store, hash-verified

203 self.assertIsInstance(group, tb.Group)
204
205 def test02_listNodes(self):
206 """Checking the File.list_nodes() method"""
207
208 if common.verbose:
209 print("\n", "-=" * 30)
210 print("Running %s.test02_listNodes..." % self.__class__.__name__)
211
212 # Made the warnings to raise an error
213 # warnings.filterwarnings("error", category=UserWarning)
214 self.h5file = tb.open_file(self.h5fname, "r")
215
216 self.assertRaises(
217 TypeError, self.h5file.list_nodes, "/", "NoSuchClass"
218 )
219
220 nodelist = [
221 "/",
222 "/group0",
223 "/group0/table1",
224 "/group0/group1/group2",
225 "/var1",
226 ]
227 nodenames = []
228 objects = []
229 for node in nodelist:
230 try:
231 objectlist = self.h5file.list_nodes(node)
232 except Exception:
233 pass
234 else:
235 objects.extend(objectlist)
236 for object in objectlist:
237 nodenames.append(object._v_pathname)
238
239 self.assertEqual(
240 nodenames,
241 [
242 "/group0",
243 "/table0",
244 "/var1",
245 "/var4",
246 "/group0/group1",
247 "/group0/table1",
248 "/group0/var1",
249 "/group0/var4",
250 ],
251 )
252 if common.verbose:
253 print("list_nodes(pathname) test passed")
254
255 nodenames = []
256 for node in objects:
257 try:
258 objectlist = self.h5file.list_nodes(node)
259 except Exception:
260 pass
261 else:
262 for object in objectlist:

Callers

nothing calls this directly

Calls 2

list_nodesMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected