mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
After upgrading `pytest-asyncio` to the latest version, lots of tests started failing in CI only on Python 3.9: `RuntimeError: There is no current event loop in thread 'MainThread'` Apparently these tests may have only been passing previously due to issues in earlier versions of `pytest-asyncio`. Changing these tests to async seems to fix the failures on Python 3.9. Related issue: https://github.com/pytest-dev/pytest-asyncio/issues/1039
26 lines
808 B
Python
26 lines
808 B
Python
from textual.app import App, ComposeResult
|
||
from textual.widgets import Log
|
||
|
||
|
||
async def test_process_line():
|
||
log = Log()
|
||
assert log._process_line("foo") == "foo"
|
||
assert log._process_line("foo\t") == "foo "
|
||
assert log._process_line("\0foo") == "<EFBFBD>foo"
|
||
|
||
|
||
async def test_disabled_log_no_attribute_error() -> None:
|
||
"""Ensure that initializing the log with disabled=True does not
|
||
raise an AttributeError.
|
||
Regression test for https://github.com/Textualize/textual/issues/5028
|
||
"""
|
||
|
||
class DisabledLogApp(App):
|
||
def compose(self) -> ComposeResult:
|
||
yield Log(disabled=True)
|
||
|
||
async with DisabledLogApp().run_test() as pilot:
|
||
# If no exception is raised, the test will pass
|
||
log = pilot.app.query_one(Log)
|
||
assert log.disabled == True
|