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

Method test04_walkNodes

tables/tests/test_tree.py:522–596  ·  view source on GitHub ↗

Checking File.walk_nodes

(self)

Source from the content-addressed store, hash-verified

520 print("walk_groups(pathname) test passed")
521
522 def test04_walkNodes(self):
523 """Checking File.walk_nodes"""
524
525 if common.verbose:
526 print("\n", "-=" * 30)
527 print("Running %s.test04_walkNodes..." % self.__class__.__name__)
528
529 self.h5file = tb.open_file(self.h5fname, "r")
530
531 self.assertRaises(
532 TypeError, next, self.h5file.walk_nodes("/", "NoSuchClass")
533 )
534
535 groups = []
536 tables1 = []
537 tables2 = []
538 arrays = []
539 for group in self.h5file.walk_nodes(classname="Group"):
540 groups.append(group._v_pathname)
541 for table in group._f_iter_nodes(classname="Table"):
542 tables1.append(table._v_pathname)
543
544 # Test the recursivity
545 for table in self.h5file.root._f_walknodes("Table"):
546 tables2.append(table._v_pathname)
547
548 for arr in self.h5file.walk_nodes(classname="Array"):
549 arrays.append(arr._v_pathname)
550
551 self.assertEqual(
552 groups, ["/", "/group0", "/group0/group1", "/group0/group1/group2"]
553 )
554 self.assertEqual(
555 tables1, ["/table0", "/group0/table1", "/group0/group1/table2"]
556 )
557 self.assertEqual(
558 tables2, ["/table0", "/group0/table1", "/group0/group1/table2"]
559 )
560 self.assertEqual(
561 arrays,
562 [
563 "/var1",
564 "/var4",
565 "/group0/var1",
566 "/group0/var4",
567 "/group0/group1/var1",
568 "/group0/group1/var4",
569 ],
570 )
571
572 if common.verbose:
573 print("File.__iter__() and Group.__iter__ test passed")
574
575 groups = []
576 tables_ = []
577 arrays = []
578 for group in self.h5file.walk_nodes(
579 "/group0/group1", classname="Group"

Callers

nothing calls this directly

Calls 4

walk_nodesMethod · 0.80
_f_iter_nodesMethod · 0.80
_f_walknodesMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected