test: unify polling waits behind a single poll_until_condition helper#1926
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1926 +/- ##
==========================================
+ Coverage 92.93% 92.99% +0.05%
==========================================
Files 167 167
Lines 11708 11708
==========================================
+ Hits 10881 10888 +7
+ Misses 827 820 -7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Replace the bespoke wait_for_condition with poll_until_condition, matching the shared helper form in apify-client-python: it polls a sync-or-async callable until an optional condition holds (default: truthy) or a wall-clock timeout expires, then returns the last result so the caller asserts explicitly. Exponential backoff is folded into a single backoff_factor parameter rather than a separate helper. Migrate every suitable hand-rolled wait to it: the five autoscaling waits, the statistics-initialization loop in the basic crawler tests, two sitemap-loader waits, and two request-queue background-task waits (fixed sleeps and range/while loops).
1952df5 to
45dd1a7
Compare
janbuchar
approved these changes
Jun 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Unifies eventually-consistent / settling waits across the test suite behind a single
poll_until_conditionhelper, matching the form shared with apify/apify-client-python#844.Changes
wait_for_conditionwithpoll_until_condition(tests/_utils.py): it polls a sync-or-async callable until an optionalconditionholds (default: truthy) or a wall-clocktimeoutexpires, then returns the last result so the caller asserts explicitly. Exponential backoff is folded into abackoff_factorargument instead of a separatecall_with_exp_backoff.tests/unit/utils.pyto the sharedtests/_utils.pyand import it relatively. This requires the test tree to be a proper package, so add__init__.pyto thetests/unitandtests/e2esubpackages that lacked one (and allowTID252in tests).sleeps andfor/whilepolling loops with the helper:test_autoscaled_pool.pytest_basic_crawler.pytest_sitemap_request_loader.pytest_request_queue.pyLint, type-check, and the full unit suite (1883 passed) pass.