mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Remove Tree class name clash with how pytest works
Just before doing the commit I decided to rename the test tree in the new unit test for clearing down a tree. Of course I managed to name it in such a way that it becomes special to pytest. This fixes that.
This commit is contained in:
@@ -20,7 +20,7 @@ class VerseMoon(VerseBody):
|
||||
pass
|
||||
|
||||
|
||||
class TestTree(Tree[VerseBody]):
|
||||
class VerseTree(Tree[VerseBody]):
|
||||
pass
|
||||
|
||||
|
||||
@@ -28,10 +28,10 @@ class TreeClearApp(App[None]):
|
||||
"""Tree clearing test app."""
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
yield TestTree("White Sun", data=VerseStar())
|
||||
yield VerseTree("White Sun", data=VerseStar())
|
||||
|
||||
def on_mount(self) -> None:
|
||||
tree = self.query_one(TestTree)
|
||||
tree = self.query_one(VerseTree)
|
||||
node = tree.root.add("Londinium", VersePlanet())
|
||||
node.add_leaf("Balkerne", VerseMoon())
|
||||
node.add_leaf("Colchester", VerseMoon())
|
||||
@@ -43,9 +43,9 @@ class TreeClearApp(App[None]):
|
||||
async def test_tree_simple_clear() -> None:
|
||||
"""Clearing a tree should keep the old label and data."""
|
||||
async with TreeClearApp().run_test() as pilot:
|
||||
tree = pilot.app.query_one(TestTree)
|
||||
tree = pilot.app.query_one(VerseTree)
|
||||
assert len(tree.root.children) > 1
|
||||
pilot.app.query_one(TestTree).clear()
|
||||
pilot.app.query_one(VerseTree).clear()
|
||||
assert len(tree.root.children) == 0
|
||||
assert str(tree.root.label) == "White Sun"
|
||||
assert isinstance(tree.root.data, VerseStar)
|
||||
@@ -54,9 +54,9 @@ async def test_tree_simple_clear() -> None:
|
||||
async def test_tree_new_label_clear() -> None:
|
||||
"""Clearing a tree with a new label should use the new label and keep the old data."""
|
||||
async with TreeClearApp().run_test() as pilot:
|
||||
tree = pilot.app.query_one(TestTree)
|
||||
tree = pilot.app.query_one(VerseTree)
|
||||
assert len(tree.root.children) > 1
|
||||
pilot.app.query_one(TestTree).clear("Jiangyin")
|
||||
pilot.app.query_one(VerseTree).clear("Jiangyin")
|
||||
assert len(tree.root.children) == 0
|
||||
assert str(tree.root.label) == "Jiangyin"
|
||||
assert isinstance(tree.root.data, VerseStar)
|
||||
|
||||
Reference in New Issue
Block a user