File tree Expand file tree Collapse file tree 4 files changed +28
-8
lines changed Expand file tree Collapse file tree 4 files changed +28
-8
lines changed Original file line number Diff line number Diff line change @@ -91,8 +91,18 @@ class Expect:
91
91
def __init__ (self ) -> None :
92
92
self ._timeout : Optional [float ] = None
93
93
94
- def set_timeout (self , timeout : float ) -> None :
95
- self ._timeout = timeout
94
+ def set_options (self , timeout : float = None ) -> None :
95
+ """
96
+ This method sets global `expect()` options.
97
+
98
+ Args:
99
+ timeout (float): Timeout value in milliseconds. Default to 5000 milliseconds.
100
+
101
+ Returns:
102
+ None
103
+ """
104
+ if timeout is not None :
105
+ self ._timeout = timeout
96
106
97
107
@overload
98
108
def __call__ (self , actual : Page , message : Optional [str ] = None ) -> PageAssertions :
Original file line number Diff line number Diff line change @@ -91,8 +91,18 @@ class Expect:
91
91
def __init__ (self ) -> None :
92
92
self ._timeout : Optional [float ] = None
93
93
94
- def set_timeout (self , timeout : float ) -> None :
95
- self ._timeout = timeout
94
+ def set_options (self , timeout : float = None ) -> None :
95
+ """
96
+ This method sets global `expect()` options.
97
+
98
+ Args:
99
+ timeout (float): Timeout value in milliseconds. Default to 5000 milliseconds.
100
+
101
+ Returns:
102
+ None
103
+ """
104
+ if timeout is not None :
105
+ self ._timeout = timeout
96
106
97
107
@overload
98
108
def __call__ (self , actual : Page , message : Optional [str ] = None ) -> PageAssertions :
Original file line number Diff line number Diff line change @@ -800,11 +800,11 @@ async def test_should_be_able_to_set_custom_timeout(page: Page) -> None:
800
800
801
801
async def test_should_be_able_to_set_custom_global_timeout (page : Page ) -> None :
802
802
try :
803
- expect .set_timeout ( 111 )
803
+ expect .set_options ( timeout = 111 )
804
804
with pytest .raises (AssertionError ) as exc_info :
805
805
await expect (page .locator ("#a1" )).to_be_visible ()
806
806
assert "LocatorAssertions.to_be_visible with timeout 111ms" in str (
807
807
exc_info .value
808
808
)
809
809
finally :
810
- expect .set_timeout ( None )
810
+ expect .set_options ( timeout = None )
Original file line number Diff line number Diff line change @@ -862,11 +862,11 @@ def test_should_be_able_to_set_custom_timeout(page: Page) -> None:
862
862
863
863
def test_should_be_able_to_set_custom_global_timeout (page : Page ) -> None :
864
864
try :
865
- expect .set_timeout ( 111 )
865
+ expect .set_options ( timeout = 111 )
866
866
with pytest .raises (AssertionError ) as exc_info :
867
867
expect (page .locator ("#a1" )).to_be_visible ()
868
868
assert "LocatorAssertions.to_be_visible with timeout 111ms" in str (
869
869
exc_info .value
870
870
)
871
871
finally :
872
- expect .set_timeout ( 5_000 )
872
+ expect .set_options ( timeout = 5_000 )
You can’t perform that action at this time.
0 commit comments