mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Add a unit test for changing DirecotryTree.path
This commit is contained in:
20
tests/directory_tree/test_change_path.py
Normal file
20
tests/directory_tree/test_change_path.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from pathlib import Path
|
||||
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.widgets import DirectoryTree
|
||||
|
||||
|
||||
class DirectoryTreeApp(App[None]):
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
yield DirectoryTree(".")
|
||||
|
||||
|
||||
async def test_change_directory_tree_path(tmpdir: Path) -> None:
|
||||
"""The DirectoryTree should react to the path changing."""
|
||||
|
||||
async with DirectoryTreeApp().run_test() as pilot:
|
||||
assert pilot.app.query_one(DirectoryTree).root.data.path == Path(".")
|
||||
pilot.app.query_one(DirectoryTree).path = tmpdir
|
||||
await pilot.pause()
|
||||
assert pilot.app.query_one(DirectoryTree).root.data.path == tmpdir
|
||||
Reference in New Issue
Block a user