Skip to content

chore: improve expect.set_options timeout reset handling #1981

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions playwright/async_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
web automation that is ever-green, capable, reliable and fast.
"""

from typing import Optional, Union, overload
from typing import Any, Optional, Union, overload

import playwright._impl._api_structures
import playwright._impl._api_types
Expand Down Expand Up @@ -88,10 +88,12 @@ def async_playwright() -> PlaywrightContextManager:


class Expect:
_unset: Any = object()

def __init__(self) -> None:
self._timeout: Optional[float] = None

def set_options(self, timeout: float = None) -> None:
def set_options(self, timeout: Optional[float] = _unset) -> None:
"""
This method sets global `expect()` options.

Expand All @@ -101,7 +103,7 @@ def set_options(self, timeout: float = None) -> None:
Returns:
None
"""
if timeout is not None:
if timeout is not self._unset:
self._timeout = timeout

@overload
Expand Down
8 changes: 5 additions & 3 deletions playwright/sync_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
web automation that is ever-green, capable, reliable and fast.
"""

from typing import Optional, Union, overload
from typing import Any, Optional, Union, overload

import playwright._impl._api_structures
import playwright._impl._api_types
Expand Down Expand Up @@ -88,10 +88,12 @@ def sync_playwright() -> PlaywrightContextManager:


class Expect:
_unset: Any = object()

def __init__(self) -> None:
self._timeout: Optional[float] = None

def set_options(self, timeout: float = None) -> None:
def set_options(self, timeout: Optional[float] = _unset) -> None:
"""
This method sets global `expect()` options.

Expand All @@ -101,7 +103,7 @@ def set_options(self, timeout: float = None) -> None:
Returns:
None
"""
if timeout is not None:
if timeout is not self._unset:
self._timeout = timeout

@overload
Expand Down