Skip to content

Commit f8c4548

Browse files
authored
chore: improve expect.set_options timeout reset handling (microsoft#1981)
1 parent f1c11fb commit f8c4548

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

playwright/async_api/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
web automation that is ever-green, capable, reliable and fast.
1919
"""
2020

21-
from typing import Optional, Union, overload
21+
from typing import Any, Optional, Union, overload
2222

2323
import playwright._impl._api_structures
2424
import playwright._impl._api_types
@@ -88,10 +88,12 @@ def async_playwright() -> PlaywrightContextManager:
8888

8989

9090
class Expect:
91+
_unset: Any = object()
92+
9193
def __init__(self) -> None:
9294
self._timeout: Optional[float] = None
9395

94-
def set_options(self, timeout: float = None) -> None:
96+
def set_options(self, timeout: Optional[float] = _unset) -> None:
9597
"""
9698
This method sets global `expect()` options.
9799
@@ -101,7 +103,7 @@ def set_options(self, timeout: float = None) -> None:
101103
Returns:
102104
None
103105
"""
104-
if timeout is not None:
106+
if timeout is not self._unset:
105107
self._timeout = timeout
106108

107109
@overload

playwright/sync_api/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
web automation that is ever-green, capable, reliable and fast.
1919
"""
2020

21-
from typing import Optional, Union, overload
21+
from typing import Any, Optional, Union, overload
2222

2323
import playwright._impl._api_structures
2424
import playwright._impl._api_types
@@ -88,10 +88,12 @@ def sync_playwright() -> PlaywrightContextManager:
8888

8989

9090
class Expect:
91+
_unset: Any = object()
92+
9193
def __init__(self) -> None:
9294
self._timeout: Optional[float] = None
9395

94-
def set_options(self, timeout: float = None) -> None:
96+
def set_options(self, timeout: Optional[float] = _unset) -> None:
9597
"""
9698
This method sets global `expect()` options.
9799
@@ -101,7 +103,7 @@ def set_options(self, timeout: float = None) -> None:
101103
Returns:
102104
None
103105
"""
104-
if timeout is not None:
106+
if timeout is not self._unset:
105107
self._timeout = timeout
106108

107109
@overload

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy