mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Fix tests.
This commit is contained in:
@@ -375,7 +375,8 @@ class Worker(Generic[ResultType]):
|
||||
|
||||
app.log.worker(Traceback())
|
||||
if self.exit_on_error:
|
||||
app._handle_exception(error)
|
||||
worker_failed = WorkerFailed(self._error)
|
||||
app._handle_exception(worker_failed)
|
||||
else:
|
||||
self.state = WorkerState.SUCCESS
|
||||
app.log.worker(self)
|
||||
|
||||
@@ -9,6 +9,7 @@ from textual.containers import Center, Middle
|
||||
from textual.pilot import OutOfBounds
|
||||
from textual.screen import Screen
|
||||
from textual.widgets import Button, Label
|
||||
from textual.worker import WorkerFailed
|
||||
|
||||
KEY_CHARACTERS_TO_TEST = "akTW03" + punctuation
|
||||
"""Test some "simple" characters (letters + digits) and all punctuation."""
|
||||
@@ -110,9 +111,10 @@ async def test_pilot_exception_catching_worker():
|
||||
async def crash(self) -> None:
|
||||
1 / 0
|
||||
|
||||
with pytest.raises(ZeroDivisionError):
|
||||
with pytest.raises(WorkerFailed) as exc:
|
||||
async with SimpleAppThatCrashes().run_test():
|
||||
pass
|
||||
assert exc.type is ZeroDivisionError
|
||||
|
||||
|
||||
async def test_pilot_click_screen():
|
||||
|
||||
@@ -113,10 +113,10 @@ async def test_run_error() -> None:
|
||||
pass
|
||||
|
||||
app = ErrorApp()
|
||||
async with app.run_test():
|
||||
worker: Worker[str] = Worker(app, run_error)
|
||||
worker._start(app)
|
||||
with pytest.raises(WorkerFailed):
|
||||
with pytest.raises(WorkerFailed):
|
||||
async with app.run_test():
|
||||
worker: Worker[str] = Worker(app, run_error)
|
||||
worker._start(app)
|
||||
await worker.wait()
|
||||
|
||||
|
||||
@@ -218,12 +218,12 @@ async def test_self_referential_deadlock():
|
||||
await get_current_worker().wait()
|
||||
|
||||
app = App()
|
||||
async with app.run_test():
|
||||
worker = Worker(app, self_referential_work)
|
||||
worker._start(app)
|
||||
with pytest.raises(WorkerFailed) as exc:
|
||||
with pytest.raises(WorkerFailed) as exc:
|
||||
async with app.run_test():
|
||||
worker = Worker(app, self_referential_work)
|
||||
worker._start(app)
|
||||
await worker.wait()
|
||||
assert exc.type is DeadlockError
|
||||
assert exc.type is DeadlockError
|
||||
|
||||
|
||||
async def test_wait_without_start():
|
||||
|
||||
Reference in New Issue
Block a user