MCPcopy Create free account
hub / github.com/apify/crawlee-python / test_resource_management

Function test_resource_management

tests/unit/browsers/test_browser_pool.py:146–158  ·  view source on GitHub ↗
(server_url: URL)

Source from the content-addressed store, hash-verified

144 reason='Test is flaky on Windows when Playwright hits net::ERR_NO_BUFFER_SPACE under xdist load.',
145)
146async def test_resource_management(server_url: URL) -> None:
147 playwright_plugin = PlaywrightBrowserPlugin(browser_type='chromium')
148
149 async with BrowserPool([playwright_plugin]) as browser_pool:
150 page = await browser_pool.new_page()
151 # Use a generous navigation timeout to avoid flakes on slow Windows CI runners.
152 await page.page.goto(str(server_url), timeout=60_000)
153 assert page.page.url == str(server_url)
154 assert '<html' in await page.page.content() # there is some HTML content
155 assert browser_pool.total_pages_count == 1
156
157 # All pages should be closed in __aexit__
158 assert page.page.is_closed()
159
160
161async def test_methods_raise_error_when_not_active() -> None:

Callers

nothing calls this directly

Calls 3

BrowserPoolClass · 0.90
new_pageMethod · 0.45

Tested by

no test coverage detected