Skip to content

Flaky Tests: Replace time.sleep race conditions in test_animate.py with deterministic assertions #1696

@pareshjoshij

Description

@pareshjoshij

Describe the bug

The tests in test_animate.py are flaky in CI environments (especially on macOS/Windows runners).

The function check_animate_output uses time.sleep() to wait for the background animation thread to produce output. If the machine is under load or just slow, the sleep finishes before the thread has written the frames, causing the test to fail with "Not enough captured characters" or assertion errors.
How to reproduce

Expected behavior
The tests should be deterministic. Instead of sleeping for a fixed arbitrary time, the test should use a polling loop (continuously reading capsys) to wait until the expected output appears or a timeout is reached. This would make the tests faster and 100% reliable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions