Skip to content

Commit 8ce602d

Browse files
committed
test: reach 100% branch coverage for diagram package
Add tests for extract.py (deep history type, internal transitions with and without actions, bidirectional compound detection, invalid input, initial state fallback), dot.py (compound labels with actions, internal action format, targetless transitions, non-bidirectional anchors), and __main__.py (via runpy). Mark unreachable branch in extract.py (history states never have substates) with pragma: no cover, and add `if __name__` to coverage exclusions in pyproject.toml.
1 parent cc20e85 commit 8ce602d

3 files changed

Lines changed: 197 additions & 116 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ exclude_lines = [
116116
"raise AssertionError",
117117
"raise NotImplementedError",
118118
"if TYPE_CHECKING",
119+
'if __name__ == "__main__"',
119120
]
120121

121122
[tool.coverage.html]

statemachine/contrib/diagram/extract.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def _extract_all_transitions(states, getter) -> List[DiagramTransition]:
131131
result.extend(_extract_all_transitions(state.states, getter))
132132
for history_state in getattr(state, "history", []):
133133
result.extend(_extract_transitions_from_state(history_state, getter))
134-
if history_state.states:
134+
if history_state.states: # pragma: no cover
135135
result.extend(_extract_all_transitions(history_state.states, getter))
136136
return result
137137

0 commit comments

Comments
 (0)