Skip to content

Commit edf1ee8

Browse files
authored
tests: fix flaky tests with timing-sensitive assertions (#1801)
1 parent d3ced60 commit edf1ee8

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

tests/unit/_utils/test_recurring_task.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ async def test_execution(function: AsyncMock, delay: timedelta) -> None:
4646
task = RecurringTask(function, delay)
4747

4848
task.start()
49-
await asyncio.sleep(0.1) # Wait enough for the task to execute a few times
49+
await asyncio.sleep(0.2) # Wait enough for the task to execute a few times
5050
await task.stop()
5151

5252
assert isinstance(task.func, AsyncMock) # To let type checker know that the function is a mock

tests/unit/crawlers/_adaptive_playwright/test_adaptive_playwright_crawler.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ async def test_adaptive_playwright_crawler_timeout_in_sub_crawler(test_urls: lis
579579
request_handler_timeout = timedelta(seconds=1)
580580

581581
crawler = AdaptivePlaywrightCrawler.with_beautifulsoup_static_parser(
582-
max_request_retries=1,
582+
max_request_retries=0,
583583
rendering_type_predictor=static_only_predictor_no_detection,
584584
request_handler_timeout=request_handler_timeout,
585585
)
@@ -594,8 +594,8 @@ async def request_handler(context: AdaptivePlaywrightCrawlingContext) -> None:
594594
mocked_browser_handler()
595595
except AdaptiveContextError:
596596
mocked_static_handler()
597-
# Relax timeout for the fallback browser request to avoid flakiness in test
598-
crawler._request_handler_timeout = timedelta(seconds=10)
597+
# Relax timeout for the fallback browser request to allow for slow browser startup on CI
598+
crawler._request_handler_timeout = timedelta(seconds=120)
599599
# Sleep for time obviously larger than top crawler timeout.
600600
await asyncio.sleep(request_handler_timeout.total_seconds() * 3)
601601

0 commit comments

Comments
 (0)