Skip to content

Commit

Permalink
raise stylesheet error
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan committed Jul 10, 2024
1 parent 18eba5c commit d2209cb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/textual/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2387,7 +2387,7 @@ def _handle_exception(self, error: Exception) -> None:
self._return_code = 1
# If we're running via pilot and this is the first exception encountered,
# take note of it so that we can re-raise for test frameworks later.
if self.is_headless and self._exception is None:
if self._exception is None:
self._exception = error
self._exception_event.set()

Expand Down
12 changes: 12 additions & 0 deletions tests/test_pilot.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from textual.app import App, ComposeResult
from textual.binding import Binding
from textual.containers import Center, Middle
from textual.css.errors import StylesheetError
from textual.pilot import OutOfBounds
from textual.screen import Screen
from textual.widgets import Button, Label
Expand Down Expand Up @@ -395,3 +396,14 @@ async def test_pilot_resize_terminal():
await pilot.pause()
assert app.size == (27, 15)
assert app.screen.size == (27, 15)


async def test_fail_early():
# https://github.com/Textualize/textual/issues/3282
class MyApp(App):
CSS_PATH = "foo.tcss"

app = MyApp()
with pytest.raises(StylesheetError):
async with app.run_test() as pilot:
await pilot.press("enter")

0 comments on commit d2209cb

Please sign in to comment.