14
14
# KIND, either express or implied. See the License for the
15
15
# specific language governing permissions and limitations
16
16
# under the License.
17
+ import re
18
+ from unittest .mock import Mock
17
19
18
20
import pytest
19
21
@@ -45,6 +47,16 @@ def test_should_get_the_size_of_the_current_window(driver):
45
47
assert size .get ("height" ) > 0
46
48
47
49
50
+ @pytest .mark .parametrize ("missing_key" , ["width" , "height" ])
51
+ def test_get_the_size_of_the_current_window_raises (driver , missing_key ):
52
+ driver .get_window_rect = Mock (return_value = {k : 100 for k in ("width" , "height" ) if k != missing_key })
53
+
54
+ with pytest .raises (
55
+ KeyError , match = re .escape (f"No size with key: { missing_key } existed in { driver .get_window_rect .return_value } " )
56
+ ):
57
+ driver .get_window_size ()
58
+
59
+
48
60
def test_should_set_the_size_of_the_current_window (driver ):
49
61
size = driver .get_window_size ()
50
62
@@ -64,6 +76,17 @@ def test_should_get_the_position_of_the_current_window(driver):
64
76
assert position .get ("y" ) >= 0
65
77
66
78
79
+ @pytest .mark .parametrize ("missing_key" , ["x" , "y" ])
80
+ def test_get_the_position_of_the_current_window_raises (driver , missing_key ):
81
+ driver .get_window_rect = Mock (return_value = {k : 100 for k in ("x" , "y" ) if k != missing_key })
82
+
83
+ with pytest .raises (
84
+ KeyError ,
85
+ match = re .escape (f"No position with key: { missing_key } existed in { driver .get_window_rect .return_value } " ),
86
+ ):
87
+ driver .get_window_position ()
88
+
89
+
67
90
def test_should_set_the_position_of_the_current_window (driver ):
68
91
position = driver .get_window_position ()
69
92
0 commit comments