parent
c018f57186
commit
7d14015e62
|
@ -96,8 +96,7 @@ class MinNode(object):
|
||||||
def leaves(self):
|
def leaves(self):
|
||||||
"Generator that returns the leaves of the tree"
|
"Generator that returns the leaves of the tree"
|
||||||
for child in self.children:
|
for child in self.children:
|
||||||
for x in child.leaves():
|
yield from child.leaves()
|
||||||
yield x
|
|
||||||
if not self.children:
|
if not self.children:
|
||||||
yield self
|
yield self
|
||||||
|
|
||||||
|
@ -277,7 +276,6 @@ def rec_test(sequence, test_func):
|
||||||
sub-iterables"""
|
sub-iterables"""
|
||||||
for x in sequence:
|
for x in sequence:
|
||||||
if isinstance(x, (list, tuple)):
|
if isinstance(x, (list, tuple)):
|
||||||
for y in rec_test(x, test_func):
|
yield from rec_test(x, test_func)
|
||||||
yield y
|
|
||||||
else:
|
else:
|
||||||
yield test_func(x)
|
yield test_func(x)
|
||||||
|
|
|
@ -194,8 +194,7 @@ class Base(object):
|
||||||
|
|
||||||
def leaves(self):
|
def leaves(self):
|
||||||
for child in self.children:
|
for child in self.children:
|
||||||
for x in child.leaves():
|
yield from child.leaves()
|
||||||
yield x
|
|
||||||
|
|
||||||
def depth(self):
|
def depth(self):
|
||||||
if self.parent is None:
|
if self.parent is None:
|
||||||
|
@ -274,16 +273,14 @@ class Node(Base):
|
||||||
def post_order(self):
|
def post_order(self):
|
||||||
"""Return a post-order iterator for the tree."""
|
"""Return a post-order iterator for the tree."""
|
||||||
for child in self.children:
|
for child in self.children:
|
||||||
for node in child.post_order():
|
yield from child.post_order()
|
||||||
yield node
|
|
||||||
yield self
|
yield self
|
||||||
|
|
||||||
def pre_order(self):
|
def pre_order(self):
|
||||||
"""Return a pre-order iterator for the tree."""
|
"""Return a pre-order iterator for the tree."""
|
||||||
yield self
|
yield self
|
||||||
for child in self.children:
|
for child in self.children:
|
||||||
for node in child.pre_order():
|
yield from child.pre_order()
|
||||||
yield node
|
|
||||||
|
|
||||||
def _prefix_getter(self):
|
def _prefix_getter(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -291,8 +291,7 @@ class TestLoader(object):
|
||||||
# tests loaded from package file
|
# tests loaded from package file
|
||||||
yield tests
|
yield tests
|
||||||
# recurse into the package
|
# recurse into the package
|
||||||
for test in self._find_tests(full_path, pattern):
|
yield from self._find_tests(full_path, pattern)
|
||||||
yield test
|
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
yield load_tests(self, tests, pattern)
|
yield load_tests(self, tests, pattern)
|
||||||
|
|
Loading…
Reference in New Issue