-
Notifications
You must be signed in to change notification settings - Fork 815
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
During tests there may be deadlocks #1608
Comments
Another example: from textual.app import App
from textual.containers import Container
from textual.screen import Screen
from textual.widget import Widget
from textual.widgets import Footer
class MyWidget(Widget):
def compose(self):
yield Footer()
class MyScreen(Screen):
def compose(self):
yield Container(MyWidget())
class MyApp(App):
def on_mount(self):
self.install_screen(MyScreen(), 'myscreen')
self.push_screen('myscreen')
async def test():
app = MyApp()
async with app.run_test():
raise Exception('never raised')
assert True |
Installed as a unit test in Textual, the most minimal version of this I can get to hang (although I can Ctrl+C it) is this: from textual.app import App
from textual.screen import Screen
from textual.widget import Widget
class MyWidget(Widget):
def compose(self):
yield Widget()
class MyScreen(Screen):
def compose(self):
yield MyWidget()
class MyApp(App):
def on_mount(self):
self.install_screen(MyScreen(), 'myscreen')
self.push_screen('myscreen')
async def test_this():
app = MyApp()
async with app.run_test():
raise Exception('never raised')
assert True If I make from textual.app import App
from textual.screen import Screen
from textual.widget import Widget
class MyWidget(Widget):
def compose(self):
yield Widget()
class MyScreen(Screen):
def compose(self):
yield MyWidget()
class MyApp(App):
async def on_mount(self):
await self.install_screen(MyScreen(), 'myscreen')
await self.push_screen('myscreen')
async def test_this():
app = MyApp()
async with app.run_test():
raise Exception('never raised')
assert True it runs to completion just fine. |
And, for the sake of completeness, just to be sure it's not some fluke and the screen isn't getting mounted but the pilot is ladning... from textual.app import App
from textual.screen import Screen
from textual.widget import Widget
class MyWidget(Widget):
def compose(self):
yield Widget()
class MyScreen(Screen):
def compose(self):
yield MyWidget()
class MyApp(App):
async def on_mount(self):
await self.install_screen(MyScreen(), 'myscreen')
await self.push_screen('myscreen')
async def test_this():
app = MyApp()
async with app.run_test() as pilot:
assert pilot.app.screen is pilot.app.get_screen("myscreen") That runs fine for me. |
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
What Operating System are you running on? Windows
In the following snippet if you uncomment the yielding of the Header the test will block:
The text was updated successfully, but these errors were encountered: