Skip to content

Relax type requirement from Sequence to Iterable for get_flattened phases #1229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion openhtf/util/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ def get_profile_filepath(cls) -> Optional[pathlib.Path]:


def get_flattened_phases(
node_collections: Sequence[
node_collections: Iterable[
Union[phase_nodes.PhaseNode, phase_collections.PhaseCollectionNode]
],
) -> Sequence[phase_nodes.PhaseNode]:
Expand Down
32 changes: 26 additions & 6 deletions test/util/test_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,16 +358,17 @@ def test_profile_test(self):
'.', os.path.sep), output)


class GetFlattenedPhasesTest(unittest.TestCase):
def no_op_phase():
"""No-op phase."""


def test_unflattens_nested_mixed_nodes(self):
def make_phase(name: str):
return openhtf.PhaseOptions(name=name)(no_op_phase)

def no_op_phase():
"""No-op phase."""

def make_phase(name: str):
return openhtf.PhaseOptions(name=name)(no_op_phase)
class GetFlattenedPhasesTest(unittest.TestCase):

def test_unflattens_nested_mixed_nodes_list(self):
nested_nodes = [
make_phase('TopLevelPhase'),
[make_phase('NestedPhase1'), make_phase('NestedPhase2')],
Expand Down Expand Up @@ -410,3 +411,22 @@ def make_phase(name: str):
'NestedPhase3',
],
)

def test_unflattens_nested_mixed_nodes_iterable(self):
nodes_iterable = openhtf.PhaseGroup(
setup=make_phase('SetupPhase1a'),
main=[make_phase('MainPhase1a'), make_phase('MainPhase1b')],
teardown=make_phase('TeardownPhase1a'),
).all_phases()
node_names = []
for node in test.get_flattened_phases(nodes_iterable):
node_names.append(node.name)
self.assertEqual(
node_names,
[
'SetupPhase1a',
'MainPhase1a',
'MainPhase1b',
'TeardownPhase1a',
],
)