# Phase Groups Example
URL: /examples/phase-groups
The upstream phase_groups.py example — six runs showing exactly when OpenHTF executes teardown phases after setup errors, main errors, nested groups and errors inside nested groups.
Six short tests that answer one question each: *does teardown run?* Based on `examples/phase_groups.py`.
Run with `-v` to see which phases execute:
Scenario
Phases that run
Teardown?
No error
setup → main → teardown
Yes
Setup returns `STOP`
setup only
**No** — group never entered
Main returns `STOP`
setup → failing main → teardown
Yes; other main phases skipped
Nested, no error
main → inner main → inner teardown → teardown
Both
Error in nested main
inner error → inner teardown → outer teardown
Both; remaining outer main skipped
Error before nested group
outer error → outer teardown
Outer only — inner never entered
Rule of thumb: **a group's teardown runs if and only if its setup completed.** "Entered" is the word upstream uses.
The explicit form. Each argument is a list of phases or nested nodes. Phase Groups →
Shorthand factory: a group with only main and teardown. `with_setup` and `with_context(setup, teardown)` exist too.
Allowed; the record gets `UNKNOWN_DUT`. Fine for a demo, not for production — see Device Under Test.