Skip to content

Commit 0189190

Browse files
committed
Format
1 parent 5f8baea commit 0189190

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

tests/unit/browsers/test_playwright_browser_controller.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
import asyncio
44
from datetime import datetime, timedelta, timezone
55
from typing import TYPE_CHECKING, Any
6-
from unittest import mock
76
from unittest.mock import AsyncMock
87

98
import pytest
109
from playwright.async_api import Browser, Playwright, async_playwright
1110

12-
from crawlee.browsers import PlaywrightBrowserController, PlaywrightBrowserPlugin, PlaywrightPersistentBrowser
11+
from crawlee.browsers import PlaywrightBrowserController, PlaywrightPersistentBrowser
1312

1413
if TYPE_CHECKING:
1514
from collections.abc import AsyncGenerator
@@ -116,17 +115,17 @@ async def test_memory_leak_on_concurrent_context_creation() -> None:
116115
# Prepare mocked browser with relevant methods and attributes
117116
mocked_browser = AsyncMock()
118117
mocked_context_launcher = AsyncMock()
119-
async def delayed_launch_persistent_context(*args: Any, **kwargs: Any) -> AsyncMock:
118+
119+
async def delayed_launch_persistent_context(*args: Any, **kwargs: Any) -> Any:
120120
"""Ensure that both calls to create context overlap in time."""
121121
await asyncio.sleep(5) # Simulate delay in creation to make sure race condition happens
122122
return await mocked_context_launcher(*args, **kwargs)
123+
123124
mocked_browser.launch_persistent_context = delayed_launch_persistent_context
124125

125126
# Create minimal instance of PlaywrightBrowserController with mocked browser
126127
controller = PlaywrightBrowserController(
127-
PlaywrightPersistentBrowser(mocked_browser,None, {}),
128-
header_generator=None,
129-
fingerprint_generator=None
128+
PlaywrightPersistentBrowser(mocked_browser, None, {}), header_generator=None, fingerprint_generator=None
130129
)
131130

132131
# Both calls will try to create browser context at the same time, but only one context should be created.

0 commit comments

Comments
 (0)