Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Textual hangs instead of exiting after raising StylesheetError if run headless #3282

Closed
tconbeer opened this issue Sep 11, 2023 · 2 comments · Fixed by #4717
Closed

Textual hangs instead of exiting after raising StylesheetError if run headless #3282

tconbeer opened this issue Sep 11, 2023 · 2 comments · Fixed by #4717

Comments

@tconbeer
Copy link
Contributor

tconbeer commented Sep 11, 2023

This program will not exit if foo.tcss does not exist:

import asyncio
from textual.app import App

class MyApp(App):
    CSS_PATH = "foo.tcss"

async def my_test():
    app = MyApp()
    async with app.run_test() as pilot:
        pilot.press("enter")

asyncio.run(my_test())

We see the StyleSheetError printed to the console, but the app then continues (or hangs).

In pytest, this test will simply hang, and not fail if the stylesheet doesn't exist:

import asyncio
from textual.app import App

@pytest.mark.asyncio
def test_cannot_find_stylesheet():
    class MyApp(App):
        CSS_PATH = "foo.tcss"
    app = MyApp()
    async with app.run_test() as pilot:
        pilot.press("enter")

In contrast, this raises and exits:

from textual.app import App

class MyApp(App):
    CSS_PATH = "foo.tcss"

app = MyApp()
app.run()

Textual Diagnostics

Versions

Name Value
Textual 0.36.0
Rich 13.5.2

Python

Name Value
Version 3.8.10
Implementation CPython
Compiler GCC 9.3.0
Executable /home/tco/.cache/pypoetry/virtualenvs/textual-stylesheet-repro-Y33mgdBe-py3.8/bin/python

Operating System

Name Value
System Linux
Release 5.10.60.1-microsoft-standard-WSL2
Version #1 SMP Wed Aug 25 23:20:18 UTC 2021

Terminal

Name Value
Terminal Application Windows Terminal
TERM xterm-256color
COLORTERM Not set
FORCE_COLOR Not set
NO_COLOR Not set

Rich Console options

Name Value
size width=156, height=40
legacy_windows False
min_width 1
max_width 156
is_terminal True
encoding utf-8
max_height 40
justify None
overflow None
no_wrap False
highlight None
markup None
height None
@github-actions
Copy link

Thank you for your issue. Give us a little time to review it.

PS. You might want to check the FAQ if you haven't done so already.

This is an automated reply, generated by FAQtory

Copy link

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant