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

Some tests fails on python 3.13 when using parallel testing #5327

Open
henri-gasc opened this issue Dec 2, 2024 · 9 comments · May be fixed by #5476
Open

Some tests fails on python 3.13 when using parallel testing #5327

henri-gasc opened this issue Dec 2, 2024 · 9 comments · May be fixed by #5476

Comments

@henri-gasc
Copy link

henri-gasc commented Dec 2, 2024

As the title said, when using python 3.13, the tests in tests/text_area fails, despite succeeding on other python version and when not running in parallel.

# Succeed
poetry run pytest tests -vvv --deselect tests/snapshot_tests/test_snapshots.py

# Fails
poetry run pytest tests -vvv --deselect tests/snapshot_tests/test_snapshots.py -n 12

Here are the logs: (add | tee pytest_[]_python3.13.txt to the command)
pytest_parallel_python3.13.txt
pytest_single_python3.13.txt

(Note that tests/text_area/test_languages.py::test_register_language and tests/text_area/test_languages.py::test_register_language_existing_language fails both time, so we don't care about them, and tests/snapshot_tests/test_snapshots.py would just pollute the logs errors)

Copy link

github-actions bot commented Dec 2, 2024

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

@TomJGooding
Copy link
Contributor

You'll need to exclude the tests marked as syntax for Python 3.13. The problem is that tree-sitter dependency for syntax highlighting doesn't build with Python 3.13 - see #5208 (comment).

@willmcgugan
Copy link
Collaborator

Yeah. We expect to have a fix quite soon.

@henri-gasc
Copy link
Author

Okay, thanks

Copy link

github-actions bot commented Dec 2, 2024

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

@henri-gasc
Copy link
Author

Wait, I did not pay attention when closing it, but using -m 'not syntax' does not solve my issue.
Here is one of the errors I want to solve:

app = TextAreaApp(title='TextAreaApp', classes={'-dark-mode'}, pseudo_classes={'dark', 'focus'})

    async def test_cursor_page_up(app: TextAreaApp):
        """Pageup moves the cursor up 1 page, retaining column index."""
        async with app.run_test() as pilot:
            text_area = app.query_one(TextArea)
            text_area.load_text("XXX\n" * 200)
            text_area.selection = Selection.cursor((100, 1))
            await pilot.press("pageup")
            margin = 2
>           assert text_area.selection == Selection.cursor(
                (100 - app.console.height + 1 + margin, 1)
            )
E           AssertionError: assert Selection(start=(78, 1), end=(78, 1)) == Selection(start=(79, 1), end=(79, 1))
E             
E             Differing attributes:
E             ['start', 'end']
E             
E             Drill down into differing attribute start:
E               start: (78, 1) != (79, 1)
E               At index 0 diff: 78 != 79
E               
E               Full diff:
E                 (
E               -     79,
E               ?      ^
E               +     78,
E               ?      ^
E                     1,
E                 )
E             
E             Drill down into differing attribute end:
E               end: (78, 1) != (79, 1)
E               At index 0 diff: 78 != 79
E               
E               Full diff:
E                 (
E               -     79,
E               ?      ^
E               +     78,
E               ?      ^
E                     1,
E                 )
E             
E             Full diff:
E             - Selection(start=(79, 1), end=(79, 1))
E             ?                   ^            ^
E             + Selection(start=(78, 1), end=(78, 1))
E             ?                   ^            ^

app        = TextAreaApp(title='TextAreaApp', classes={'-dark-mode'}, pseudo_classes={'dark', 'focus'})
margin     = 2
pilot      = <Pilot app=TextAreaApp(title='TextAreaApp', classes={'-dark-mode'}, pseudo_classes={'dark', 'focus'})>
text_area  = TextArea()

tests/text_area/test_selection_bindings.py:270: AssertionError

@henri-gasc henri-gasc reopened this Dec 2, 2024
@darrenburns
Copy link
Member

I can't reproduce this on MacOS. Could you try again on the latest main @henri-gasc? I just merged an update.

@henri-gasc
Copy link
Author

It still does not work. The errors are:

FAILED tests/text_area/test_selection_bindings.py::test_cursor_page_down[True] - AssertionError: assert Selection(start=(22, 1), end=(22, 1)) == Selection(start=(39, 1), end=(39, 1))
FAILED tests/text_area/test_selection_bindings.py::test_cursor_page_down[False] - AssertionError: assert Selection(start=(22, 1), end=(22, 1)) == Selection(start=(39, 1), end=(39, 1))
FAILED tests/text_area/test_selection_bindings.py::test_cursor_page_up[True] - AssertionError: assert Selection(start=(78, 1), end=(78, 1)) == Selection(start=(61, 1), end=(61, 1))
FAILED tests/text_area/test_selection_bindings.py::test_cursor_page_up[False] - AssertionError: assert Selection(start=(78, 1), end=(78, 1)) == Selection(start=(61, 1), end=(61, 1))

Like before, in single mode those errors does happens.

@TomJGooding
Copy link
Contributor

Just to confirm that after upgrading to Python 3.13, I'm also now seeing these same tests fail when run in parallel.

I thought this might be something to do with the fixture in test_selection_bindings.py, but then why do the other tests pass? Weird this only seems to happen with Python 3.13!

TomJGooding added a commit to TomJGooding/textual that referenced this issue Jan 16, 2025
Fixes Textualize#5327.

Normally when running tests with Textual, the default size of the
simulated app is 80x24. However it seems when tests are run in parallel
with xdist on Python 3.13, `app.console.height` returns the _actual_
height of the terminal, causing tests to fail.
@TomJGooding TomJGooding linked a pull request Jan 16, 2025 that will close this issue
3 tasks
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.

4 participants