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:
9191 def __init__ (self ) -> None :
9292 self ._timeout : Optional [float ] = None
9393
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
96106
97107 @overload
98108 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:
9191 def __init__ (self ) -> None :
9292 self ._timeout : Optional [float ] = None
9393
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
96106
97107 @overload
98108 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:
800800
801801async def test_should_be_able_to_set_custom_global_timeout (page : Page ) -> None :
802802 try :
803- expect .set_timeout ( 111 )
803+ expect .set_options ( timeout = 111 )
804804 with pytest .raises (AssertionError ) as exc_info :
805805 await expect (page .locator ("#a1" )).to_be_visible ()
806806 assert "LocatorAssertions.to_be_visible with timeout 111ms" in str (
807807 exc_info .value
808808 )
809809 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:
862862
863863def test_should_be_able_to_set_custom_global_timeout (page : Page ) -> None :
864864 try :
865- expect .set_timeout ( 111 )
865+ expect .set_options ( timeout = 111 )
866866 with pytest .raises (AssertionError ) as exc_info :
867867 expect (page .locator ("#a1" )).to_be_visible ()
868868 assert "LocatorAssertions.to_be_visible with timeout 111ms" in str (
869869 exc_info .value
870870 )
871871 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