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

Pytest gets stuck when testing app with dynamically mounting animated widgets on timer #4866

Closed
Zaloog opened this issue Aug 11, 2024 · 5 comments

Comments

@Zaloog
Copy link
Contributor

Zaloog commented Aug 11, 2024

When testing my app with pytest, the test doesnt continue at a certain point.

Testfile: https://github.com/Zaloog/idle-tui-adventures/blob/main/tests/test_app.py

My initial guess was an issue with 2 intervalls running at the same in my app.
But after some debugging, its just the one timer, that makes the test stop.

My assumption is, that it has to do with the mounting of the damage widgets, which are Labels initialized with this method called:

    def fly_away(self):
        self.styles.animate(
            attribute="opacity",
            value=0,
            duration=1.5,
        )

        self.animate(
            attribute="offset",
            value=Offset(self.parent_center[0] + self.wiggle, 0),
            duration=1.0,
            on_complete=self.remove,
            easing="out_expo",
        )

Here is a short clip to show what that looks like:
https://github.com/user-attachments/assets/08c72ad2-36c2-4018-97f2-c794d2aadbbf

Textual Diagnostics

Versions

Name Value
Textual 0.76.0
Rich 13.7.1

Python

Name Value
Version 3.12.2
Implementation CPython
Compiler MSC v.1929 64 bit (AMD64)
Executable C:\Users\grams\rye_projects\idle-tui-adventures.venv\Scripts\python.exe

Operating System

Name Value
System Windows
Release 11
Version 10.0.22631

Terminal

Name Value
Terminal Application Windows Terminal
TERM Not set
COLORTERM Not set
FORCE_COLOR Not set
NO_COLOR Not set

Rich Console options

Name Value
size width=141, height=55
legacy_windows False
min_width 1
max_width 141
is_terminal True
encoding utf-8
max_height 55
justify None
overflow None
no_wrap False
highlight None
markup None
height None

PyTest Setup:

  • platform win32 -- Python 3.12.2, pytest-8.3.2, pluggy-1.5.0
  • plugins: asyncio-0.23.8, cov-5.0.0, xdist-3.6.1
Copy link

We found the following entries in the FAQ which you may find helpful:

Feel free to close this issue if you found an answer in the FAQ. Otherwise, please give us a little time to review.

This is an automated reply, generated by FAQtory

@Zaloog Zaloog changed the title Pytest hangs itself when testing app with dynamically mounting animated widgets on timer Pytest gets stuck when testing app with dynamically mounting animated widgets on timer Aug 11, 2024
@willmcgugan
Copy link
Collaborator

Are you doing a lot of animation? The test system will wait for animation to complete after keys / clicks etc. This is so the snapshot can be taken at a point where the state is knowable. But it does mean that if you are always animating, it will never return!

@Zaloog
Copy link
Contributor Author

Zaloog commented Aug 12, 2024

Currently around every second, but its dependend on an attack_speed variable, so in the application itself it might be faster.
But if I define like a test_character with attack_speed of e.g. 0.5 -> animation appear interval would be 2s and the longer animation itself takes 1.5 s, so the animation can complete, before a new one appears.

Edit:
Nvm, quickly tested it, jep that fixes it.
So I guess for testing lower the animation speed, i.e. attack speed

Thanks @willmcgugan

@Zaloog
Copy link
Contributor Author

Zaloog commented Aug 12, 2024

ill close this then

@Zaloog Zaloog closed this as completed Aug 12, 2024
Copy link

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

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

No branches or pull requests

2 participants