11from textual .app import App
22from textual .screen import Screen
3- from textual .widgets import Header
3+ from textual .widgets import Header , Static
44
55
66async def test_screen_title_none_is_ignored ():
@@ -16,7 +16,7 @@ def on_mount(self):
1616
1717 app = MyApp ()
1818 async with app .run_test ():
19- assert app .screen .query_one ("HeaderTitle" ). text == "app title"
19+ assert app .screen .query_one ("HeaderTitle" , Static ). content == "app title"
2020
2121
2222async def test_screen_title_overrides_app_title ():
@@ -34,7 +34,7 @@ def on_mount(self):
3434
3535 app = MyApp ()
3636 async with app .run_test ():
37- assert app .screen .query_one ("HeaderTitle" ). text == "screen title"
37+ assert app .screen .query_one ("HeaderTitle" , Static ). content == "screen title"
3838
3939
4040async def test_screen_title_reactive_updates_title ():
@@ -54,7 +54,7 @@ def on_mount(self):
5454 async with app .run_test () as pilot :
5555 app .screen .title = "new screen title"
5656 await pilot .pause ()
57- assert app .screen .query_one ("HeaderTitle" ). text == "new screen title"
57+ assert app .screen .query_one ("HeaderTitle" , Static ). content == "new screen title"
5858
5959
6060async def test_app_title_reactive_does_not_update_title_when_screen_title_is_set ():
@@ -74,7 +74,7 @@ def on_mount(self):
7474 async with app .run_test () as pilot :
7575 app .title = "new app title"
7676 await pilot .pause ()
77- assert app .screen .query_one ("HeaderTitle" ). text == "screen title"
77+ assert app .screen .query_one ("HeaderTitle" , Static ). content == "screen title"
7878
7979
8080async def test_screen_sub_title_none_is_ignored ():
@@ -90,7 +90,10 @@ def on_mount(self):
9090
9191 app = MyApp ()
9292 async with app .run_test ():
93- assert app .screen .query_one ("HeaderTitle" ).sub_text == "app sub-title"
93+ assert (
94+ app .screen .query_one ("HeaderTitle" , Static ).content
95+ == "MyApp — app sub-title"
96+ )
9497
9598
9699async def test_screen_sub_title_overrides_app_sub_title ():
@@ -108,7 +111,10 @@ def on_mount(self):
108111
109112 app = MyApp ()
110113 async with app .run_test ():
111- assert app .screen .query_one ("HeaderTitle" ).sub_text == "screen sub-title"
114+ assert (
115+ app .screen .query_one ("HeaderTitle" , Static ).content
116+ == "MyApp — screen sub-title"
117+ )
112118
113119
114120async def test_screen_sub_title_reactive_updates_sub_title ():
@@ -128,24 +134,7 @@ def on_mount(self):
128134 async with app .run_test () as pilot :
129135 app .screen .sub_title = "new screen sub-title"
130136 await pilot .pause ()
131- assert app .screen .query_one ("HeaderTitle" ).sub_text == "new screen sub-title"
132-
133-
134- async def test_app_sub_title_reactive_does_not_update_sub_title_when_screen_sub_title_is_set ():
135- class MyScreen (Screen ):
136- SUB_TITLE = "screen sub-title"
137-
138- def compose (self ):
139- yield Header ()
140-
141- class MyApp (App ):
142- SUB_TITLE = "app sub-title"
143-
144- def on_mount (self ):
145- self .push_screen (MyScreen ())
146-
147- app = MyApp ()
148- async with app .run_test () as pilot :
149- app .sub_title = "new app sub-title"
150- await pilot .pause ()
151- assert app .screen .query_one ("HeaderTitle" ).sub_text == "screen sub-title"
137+ assert (
138+ app .screen .query_one ("HeaderTitle" , Static ).content
139+ == "MyApp — new screen sub-title"
140+ )
0 commit comments