Skip to content

Commit 69e259f

Browse files
committed
add tests
1 parent 88a8bd5 commit 69e259f

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1010
### Fixed
1111

1212
- Fixed crash when exiting the app prematurely https://github.com/Textualize/textual/pull/5039
13+
- Fixed exception constructing TextArea outside of App
1314

1415
## [0.80.0] - 2024-09-23
1516

tests/test_widget.py

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,46 @@
1212
from textual.geometry import Offset, Size
1313
from textual.message import Message
1414
from textual.widget import BadWidgetName, MountError, PseudoClasses, Widget
15-
from textual.widgets import Label, LoadingIndicator
15+
from textual.widgets import (
16+
Button,
17+
DataTable,
18+
Footer,
19+
Header,
20+
Input,
21+
Label,
22+
LoadingIndicator,
23+
Log,
24+
OptionList,
25+
RichLog,
26+
Switch,
27+
TextArea,
28+
)
29+
30+
31+
async def test_widget_construct():
32+
"""Regression test for https://github.com/Textualize/textual/issues/5042"""
33+
34+
# Check that constructing the widget outside of the app, doesn't invoke code that
35+
# expects an active app.
36+
class MyApp(App):
37+
def __init__(self) -> None:
38+
super().__init__()
39+
self.button = Button()
40+
self.data_table = DataTable()
41+
self.footer = Footer()
42+
self.header = Header()
43+
self.input = Input()
44+
self.label = Label()
45+
self.loading_indicator = LoadingIndicator()
46+
self.log = Log()
47+
self.option_list = OptionList()
48+
self.rich_log = RichLog()
49+
self.switch = Switch()
50+
self.text_area = TextArea(language="python")
51+
52+
app = MyApp()
53+
async with app.run_test():
54+
pass
1655

1756

1857
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)