@@ -1090,3 +1090,27 @@ def test_ncol_ncols(fig_test, fig_ref):
1090
1090
ncols = 3
1091
1091
fig_test .legend (strings , ncol = ncols )
1092
1092
fig_ref .legend (strings , ncols = ncols )
1093
+
1094
+
1095
+ def test_loc_invalid_tuple_exception ():
1096
+ # check that exception is raised if the loc arg
1097
+ # of legend is not a 2-tuple of numbers
1098
+ fig , ax = plt .subplots ()
1099
+ with pytest .raises (ValueError ,
1100
+ match = "loc must be string or pair of numbers, not "
1101
+ "\\ (1.1\\ ,\\ )" ): # regex escape special chars
1102
+ ax .legend (loc = (1.1 , ))
1103
+ with pytest .raises (ValueError ,
1104
+ match = "loc must be string or pair of numbers, not "
1105
+ "\\ (0.481\\ , 0.4227\\ , 0.4523\\ )" ):
1106
+ ax .legend (loc = (0.481 , 0.4227 , 0.4523 ))
1107
+ with pytest .raises (ValueError ,
1108
+ match = "loc must be string or pair of numbers, not "
1109
+ "\\ (0.481\\ , \\ 'go blue\\ '\\ )" ):
1110
+ ax .legend (loc = (0.481 , "go blue" ))
1111
+
1112
+
1113
+ def test_loc_valid_tuple ():
1114
+ fig , ax = plt .subplots ()
1115
+ ax .legend (loc = (0.481 , 0.442 ))
1116
+ ax .legend (loc = (1 , 2 ))
0 commit comments