Skip to content

Commit 94a6401

Browse files
committed
fix: setDefaultTimeout
1 parent 875b380 commit 94a6401

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

playwright/sync_base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ def __str__(self) -> str:
8484
return self._impl_obj.__str__()
8585

8686
def _sync(self, task: asyncio.Future) -> Any:
87+
if not task:
88+
return None
8789
g_self = greenlet.getcurrent()
8890
future = self._loop.create_task(task)
8991

tests/test_sync.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import pytest
1818

19-
from playwright import Error, sync_playwright
19+
from playwright import Error, TimeoutError, sync_playwright
2020
from playwright.sync_api import Browser, Page
2121

2222

@@ -214,3 +214,10 @@ def test_sync_playwright_multiple_times():
214214
with sync_playwright() as pw2:
215215
assert pw1.chromium == pw2.chromium
216216
assert "Can only run one Playwright at a time." in exc.value.message
217+
218+
219+
def test_sync_set_default_timeout(page):
220+
page.setDefaultTimeout(1)
221+
with pytest.raises(TimeoutError) as exc:
222+
page.waitForFunction("false")
223+
assert "Timeout 1ms exceeded." in exc.value.message

0 commit comments

Comments
 (0)