Skip to content

Commit 55725d5

Browse files
authored
test: unflake tests (#2768)
1 parent 8533973 commit 55725d5

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

tests/async/test_defaultbrowsercontext.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,22 @@
2121
Awaitable,
2222
Callable,
2323
Dict,
24+
List,
2425
Literal,
2526
Optional,
2627
Tuple,
2728
)
2829

2930
import pytest
3031

31-
from playwright.async_api import BrowserContext, BrowserType, Error, Page, expect
32+
from playwright.async_api import (
33+
BrowserContext,
34+
BrowserType,
35+
Cookie,
36+
Error,
37+
Page,
38+
expect,
39+
)
3240
from tests.server import Server
3341
from tests.utils import must
3442

@@ -116,6 +124,12 @@ async def test_context_add_cookies_should_work(
116124
]
117125

118126

127+
def _filter_cookies(cookies: List[Cookie]) -> List[Cookie]:
128+
return list(
129+
filter(lambda cookie: cookie["domain"] != "copilot.microsoft.com", cookies)
130+
)
131+
132+
119133
async def test_context_clear_cookies_should_work(
120134
server: Server,
121135
launch_persistent: "Callable[..., asyncio.Future[Tuple[Page, BrowserContext]]]",
@@ -131,7 +145,7 @@ async def test_context_clear_cookies_should_work(
131145
assert await page.evaluate("document.cookie") == "cookie1=1; cookie2=2"
132146
await page.context.clear_cookies()
133147
await page.reload()
134-
assert await page.context.cookies([]) == []
148+
assert _filter_cookies(await page.context.cookies([])) == []
135149
assert await page.evaluate("document.cookie") == ""
136150

137151

tests/async/test_selector_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ async def test_should_use_data_test_id_in_strict_errors(
4040
"""
4141
)
4242
with pytest.raises(Error) as exc_info:
43-
await page.locator(".foo").hover(timeout=200)
43+
await page.locator(".foo").hover()
4444
assert "strict mode violation" in exc_info.value.message
4545
assert '<div class="foo bar:0' in exc_info.value.message
4646
assert '<div class="foo bar:1' in exc_info.value.message

0 commit comments

Comments
 (0)