Skip to content

test: replace polling sleeps with poll_until fixture#146

Merged
pratyush618 merged 1 commit into
masterfrom
test/replace-time-sleep
May 8, 2026
Merged

test: replace polling sleeps with poll_until fixture#146
pratyush618 merged 1 commit into
masterfrom
test/replace-time-sleep

Conversation

@pratyush618
Copy link
Copy Markdown
Collaborator

Summary

Adds a poll_until pytest fixture in tests/python/conftest.py and rewrites 35+ time.sleep calls across 13 test files to wait on the actual condition (event delivery, webhook delivery, async-executor completion, DLQ entry, worker registration, job state) instead of fixed delays. The remaining time.sleep calls are intentional pacing inside task bodies (the test asserts the worker handles a slow task) — those keep their behaviour, and the rate-limit / retry tests continue to rely on time-based pacing where the assertion is about throughput.

This addresses recommendation 6 from the 2026-05-08 audit (.claude/reports/audit-2026-05-08.md).

Net diff: 13 files, +186 / -112 lines.

Files touched

  • tests/python/conftest.py — adds the poll_until fixture.
  • tests/python/test_events.py, test_webhooks.py, test_native_async.py, test_customizability.py — wait-for-event/wait-for-webhook/wait-for-executor patterns.
  • tests/python/test_dlq.py, test_retry.py, test_periodic.py — wait-for-DLQ-entry / wait-for-completion patterns.
  • tests/python/test_resources.py, test_worker_resources.py — wait-for-runtime-state / heartbeat publication.
  • tests/python/test_shutdown.py, test_prefork.py, test_priority.py — wait-for-running and wait-for-completion patterns.

Workflow test files (test_workflows_*.py) are intentionally not part of this PR — they overlap with the conftest changes already in flight on test/workflow-worker-fixture and will be cleaned up in a follow-up to keep diffs small.

Test plan

  • uv run python -m pytest tests/python/test_events.py tests/python/test_webhooks.py tests/python/test_native_async.py tests/python/test_customizability.py tests/python/test_dlq.py tests/python/test_periodic.py tests/python/test_retry.py tests/python/test_resources.py tests/python/test_shutdown.py tests/python/test_worker_resources.py tests/python/test_priority.py — 93 passed.
  • uv run ruff check tests/python/ — clean.
  • uv run mypy py_src/taskito/ tests/python/ --no-incremental — clean.
  • Full Python suite passes in CI.

@github-actions github-actions Bot added the tests label May 8, 2026
@pratyush618 pratyush618 force-pushed the test/replace-time-sleep branch from 48ab28e to b0d317b Compare May 8, 2026 04:18
@pratyush618 pratyush618 merged commit ed33716 into master May 8, 2026
19 checks passed
@pratyush618 pratyush618 deleted the test/replace-time-sleep branch May 8, 2026 04:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant