Run a dummy app.
()
| 20 | |
| 21 | |
| 22 | async def run_app() -> None: |
| 23 | """Run a dummy app.""" |
| 24 | |
| 25 | class DummyApp(App): |
| 26 | """Dummy app with a few widgets.""" |
| 27 | |
| 28 | def compose(self) -> ComposeResult: |
| 29 | yield Header() |
| 30 | with Vertical(): |
| 31 | yield Label("foo") |
| 32 | yield Label("bar") |
| 33 | yield Footer() |
| 34 | |
| 35 | app = DummyApp() |
| 36 | |
| 37 | async with app.run_test() as pilot: |
| 38 | # We should have a bunch of DOMNodes while the test is running |
| 39 | assert count_nodes() > 0 |
| 40 | await pilot.press("ctrl+c") |
| 41 | |
| 42 | assert not app._running |
| 43 | |
| 44 | # Force a GC collection |
| 45 | gc.collect() |
| 46 | |
| 47 | # After the test, all DOMNodes will have been torn down |
| 48 | assert count_nodes() == 1 |
| 49 | |
| 50 | |
| 51 | async def _count_app_nodes() -> None: |
no test coverage detected
searching dependent graphs…