diff --git a/tests/e2e/project_template/test_static_crawlers_templates.py b/tests/e2e/project_template/test_static_crawlers_templates.py index 9486cba921..f50107a8a9 100644 --- a/tests/e2e/project_template/test_static_crawlers_templates.py +++ b/tests/e2e/project_template/test_static_crawlers_templates.py @@ -47,6 +47,10 @@ pytest.param('poetry', marks=pytest.mark.poetry), ], ) +@pytest.mark.flaky( + reruns=3, + reason='`apify push` occasionally hangs against the Apify platform; retries cover transient CLI/network flakes.', +) async def test_static_crawler_actor_at_apify( tmp_path: Path, crawlee_wheel_path: Path, @@ -80,14 +84,21 @@ async def test_static_crawler_actor_at_apify( # Print apify version for debugging purposes in rare cases of CLI failures subprocess.run(['apify', '--version'], check=True) # noqa: ASYNC221, S607 - # Build actor using sequence of cli commands as the user would + # Build actor using sequence of cli commands as the user would. subprocess.run( # noqa: ASYNC221, S603 ['apify', 'login', '-t', os.environ['APIFY_TEST_USER_API_TOKEN']], # noqa: S607 capture_output=True, check=True, cwd=tmp_path / actor_name, + timeout=120, + ) + subprocess.run( # noqa: ASYNC221, S603 + ['apify', 'init', '-y', actor_name], # noqa: S607 + capture_output=True, + check=True, + cwd=tmp_path / actor_name, + timeout=120, ) - subprocess.run(['apify', 'init', '-y', actor_name], capture_output=True, check=True, cwd=tmp_path / actor_name) # noqa: ASYNC221, S603, S607 build_process = subprocess.run( # noqa: ASYNC221 ['apify', 'push'], # noqa: S607 @@ -97,6 +108,7 @@ async def test_static_crawler_actor_at_apify( # Prevent git from walking up into the surrounding project's .git/ when running under # a basetemp inside the repo (see --basetemp in the e2e-templates-tests poe task). env={**os.environ, 'GIT_CEILING_DIRECTORIES': str(tmp_path)}, + timeout=120, ) # Get actor ID from build log actor_id_regexp = re.compile(r'https:\/\/console\.apify\.com\/actors\/(.*)#\/builds\/\d*\.\d*\.\d*') diff --git a/tests/unit/browsers/test_browser_pool.py b/tests/unit/browsers/test_browser_pool.py index 15990cfec1..f04530a609 100644 --- a/tests/unit/browsers/test_browser_pool.py +++ b/tests/unit/browsers/test_browser_pool.py @@ -74,7 +74,7 @@ async def test_multiple_plugins_new_page_creation(server_url: URL) -> None: @pytest.mark.flaky( - rerun=3, + reruns=3, reason='Test is flaky on Windows and MacOS, see https://github.com/apify/crawlee-python/issues/1660.', ) async def test_new_page_with_each_plugin(server_url: URL) -> None: diff --git a/tests/unit/browsers/test_stagehand_browser_controller.py b/tests/unit/browsers/test_stagehand_browser_controller.py index 3139913477..effc5cd7b5 100644 --- a/tests/unit/browsers/test_stagehand_browser_controller.py +++ b/tests/unit/browsers/test_stagehand_browser_controller.py @@ -342,7 +342,7 @@ async def test_proxy_set_browserbase( @pytest.mark.flaky( - rerun=3, + reruns=3, reason='Test is flaky on Windows when Playwright hits net::ERR_NO_BUFFER_SPACE under xdist load.', ) async def test_fingerprint_headers_set_on_new_page(controller: StagehandBrowserController, server_url: URL) -> None: diff --git a/tests/unit/crawlers/_adaptive_playwright/test_adaptive_playwright_crawler.py b/tests/unit/crawlers/_adaptive_playwright/test_adaptive_playwright_crawler.py index 119bc5e8ea..e36c95dde0 100644 --- a/tests/unit/crawlers/_adaptive_playwright/test_adaptive_playwright_crawler.py +++ b/tests/unit/crawlers/_adaptive_playwright/test_adaptive_playwright_crawler.py @@ -238,7 +238,7 @@ async def request_handler(context: AdaptivePlaywrightCrawlingContext) -> None: @pytest.mark.flaky( - rerun=3, + reruns=3, reason='Test is flaky on Windows when Playwright hits net::ERR_NO_BUFFER_SPACE and retries, ' 'causing the pre-nav hook to fire one extra time.', ) @@ -637,7 +637,7 @@ async def request_handler(context: AdaptivePlaywrightCrawlingContext) -> None: @pytest.mark.flaky( - rerun=3, + reruns=3, reason='Test is flaky on Windows and MacOS, see https://github.com/apify/crawlee-python/issues/1650.', ) async def test_adaptive_context_query_selector_beautiful_soup(test_urls: list[str]) -> None: @@ -683,7 +683,7 @@ async def request_handler(context: AdaptivePlaywrightCrawlingContext) -> None: @pytest.mark.flaky( - rerun=3, + reruns=3, reason='Test is flaky on Windows and MacOS, see https://github.com/apify/crawlee-python/issues/1650.', ) async def test_adaptive_context_query_selector_parsel(test_urls: list[str]) -> None: