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

Fail test_textual.py due to recent textual._xterm_parser.XTermParser change #7117

Closed
cdeil opened this issue Aug 10, 2024 · 2 comments · Fixed by #7130
Closed

Fail test_textual.py due to recent textual._xterm_parser.XTermParser change #7117

cdeil opened this issue Aug 10, 2024 · 2 comments · Fixed by #7130

Comments

@cdeil
Copy link
Contributor

cdeil commented Aug 10, 2024

For me with git main latest 9404b43 I get this test fail:

_________________________________________________________________________________________________ test_textual_app _________________________________________________________________________________________________

page = <Page url='http://localhost:60618/'>

    def test_textual_app(page):
        clicks = []
    
        def app():
            # Has to be run on the thread
            class ButtonApp(App):
    
                def compose(self):
                    yield Button("Default")
    
                def on_button_pressed(self, event: Button.Pressed) -> None:
                    clicks.append(event)
    
            app = ButtonApp()
            textual = Textual(app)
            return textual
    
        serve_component(page, app)
    
        expect(page.locator(".xterm-screen")).to_have_count(1)
    
>       wait_until(lambda: bool(page.mouse.click(50, 50) or clicks), page)
E       TimeoutError: wait_until timed out in 5000 milliseconds

panel/tests/ui/pane/test_textual.py:43: TimeoutError
----------------------------------------------------------------------------------------------- Captured stdout call -----------------------------------------------------------------------------------------------
Launching server at http://localhost:60618
----------------------------------------------------------------------------------------------- Captured stderr call -----------------------------------------------------------------------------------------------
╭───────────────────── Traceback (most recent call last) ──────────────────────╮
│ /Users/cdeil/code/oss/panel/.pixi/envs/test-ui/lib/python3.12/site-packages/ │
│ textual/app.py:2592 in _process_messages                                     │
│                                                                              │
│   2589 │   │   │   self.log(driver=driver)                                   │
│   2590 │   │   │                                                             │
│   2591 │   │   │   if not self._exit:                                        │
│ ❱ 2592 │   │   │   │   driver.start_application_mode()                       │
│   2593 │   │   │   │   try:                                                  │
│   2594 │   │   │   │   │   with redirect_stdout(self._capture_stdout):       │
│   2595 │   │   │   │   │   │   with redirect_stderr(self._capture_stderr):   │
│                                                                              │
│ ╭───────────────────────────────── locals ─────────────────────────────────╮ │
│ │                  css = '\n    App {\n        background: $background;\n  │ │
│ │                        color: $text;\n    }\n    *:di'+51                │ │
│ │               driver = <panel.pane._textual.PanelDriver object at        │ │
│ │                        0x147508620>                                      │ │
│ │                error = TypeError('XTermParser.__init__() takes from 1 to │ │
│ │                        2 positional arguments but 3 were given')         │ │
│ │             headless = False                                             │ │
│ │               inline = False                                             │ │
│ │      inline_no_clear = False                                             │ │
│ │           load_event = Load()                                            │ │
│ │         message_hook = None                                              │ │
│ │                mouse = True                                              │ │
│ │            read_from = (                                                 │ │
│ │                        │                                                 │ │
│ │                        '/Users/cdeil/code/oss/panel/.pixi/envs/test-ui/… │ │
│ │                        │   'App.DEFAULT_CSS'                             │ │
│ │                        )                                                 │ │
│ │       ready_callback = None                                              │ │
│ │ run_process_messages = <function                                         │ │
│ │                        App._process_messages.<locals>.run_process_messa… │ │
│ │                        at 0x14763cd60>                                   │ │
│ │                scope = 'App'                                             │ │
│ │                 self = ButtonApp(                                        │ │
│ │                        │   title='ButtonApp',                            │ │
│ │                        │   classes={'-dark-mode'}                        │ │
│ │                        )                                                 │ │
│ │        terminal_size = (0, 0)                                            │ │
│ │          tie_breaker = -1                                                │ │
│ ╰──────────────────────────────────────────────────────────────────────────╯ │
│                                                                              │
│ /Users/cdeil/code/oss/panel/panel/pane/_textual.py:80 in                     │
│ start_application_mode                                                       │
│                                                                              │
│   77 │                                                                       │
│   78 │   def start_application_mode(self):                                   │
│   79 │   │   self._size_watcher = self._terminal.param.watch(self._resize, [ │
│ ❱ 80 │   │   self._parser = XTermParser(lambda: False, self._debug)          │
│   81 │   │   self._input_watcher = self._terminal.param.watch(self._process_ │
│   82 │                                                                       │
│   83 │   def stop_application_mode(self):                                    │
│                                                                              │
│ ╭──────────────────────────── locals ────────────────────────────╮           │
│ │ self = <panel.pane._textual.PanelDriver object at 0x147508620> │           │
│ ╰────────────────────────────────────────────────────────────────╯           │
╰──────────────────────────────────────────────────────────────────────────────╯
TypeError: XTermParser.__init__() takes from 1 to 2 positional arguments but 3 
were given

The reason is that textual 0.76.0 shipped a breaking change:

https://github.com/Textualize/textual/pull/4848/files#diff-2e510f9ff3061a8ebb215a28586d93430b35b5214ba7bc6b2e54e5d29f717fb0L41-R45

Is there a way to use a public API and avoid the private import?

from textual._xterm_parser import XTermParser

Or handle it with an if/else to support both old and new version of textual?

@hoxbro
Copy link
Member

hoxbro commented Aug 10, 2024

You can add an upper pin to pixi.toml for now

@philippjfr
Copy link
Member

Had a look around but didn't find a public API.

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.

3 participants