@@ -1090,3 +1090,28 @@ 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\\ ,\\ )" ): # escape special chars for
1102
+ # regex
1103
+ ax .legend (loc = (1.1 , ))
1104
+ with pytest .raises (ValueError ,
1105
+ match = "loc must be string or pair of numbers, not "
1106
+ "\\ (0.481\\ , 0.4227\\ , 0.4523\\ )" ):
1107
+ ax .legend (loc = (0.481 , 0.4227 , 0.4523 ))
1108
+ with pytest .raises (ValueError ,
1109
+ match = "loc must be string or pair of numbers, not "
1110
+ "\\ (0.481\\ , \\ 'go blue\\ '\\ )" ):
1111
+ ax .legend (loc = (0.481 , "go blue" ))
1112
+
1113
+
1114
+ def test_loc_valid_tuple ():
1115
+ fig , ax = plt .subplots ()
1116
+ ax .legend (loc = (0.481 , 0.442 ))
1117
+ ax .legend (loc = (1 , 2 ))
0 commit comments