@@ -187,7 +187,7 @@ def test_rgb_tuple_color(self):
187
187
188
188
def test_color_empty_string (self ):
189
189
df = DataFrame (randn (10 , 2 ))
190
- with pytest .raises (ValueError ):
190
+ with pytest .raises (ValueError , match = msg ):
191
191
df .plot (color = "" )
192
192
193
193
def test_color_and_style_arguments (self ):
@@ -203,7 +203,7 @@ def test_color_and_style_arguments(self):
203
203
assert color == ["red" , "black" ]
204
204
# passing both 'color' and 'style' arguments should not be allowed
205
205
# if there is a color symbol in the style strings:
206
- with pytest .raises (ValueError ):
206
+ with pytest .raises (ValueError , match = msg ):
207
207
df .plot (color = ["red" , "black" ], style = ["k-" , "r--" ])
208
208
209
209
def test_nonnumeric_exclude (self ):
@@ -628,9 +628,9 @@ def test_subplots_layout(self):
628
628
self ._check_axes_shape (axes , axes_num = 3 , layout = (4 , 1 ))
629
629
assert axes .shape == (4 , 1 )
630
630
631
- with pytest .raises (ValueError ):
631
+ with pytest .raises (ValueError , match = msg ):
632
632
df .plot (subplots = True , layout = (1 , 1 ))
633
- with pytest .raises (ValueError ):
633
+ with pytest .raises (ValueError , match = msg ):
634
634
df .plot (subplots = True , layout = (- 1 , - 1 ))
635
635
636
636
# single column
@@ -673,7 +673,7 @@ def test_subplots_multiple_axes(self):
673
673
self ._check_axes_shape (axes , axes_num = 6 , layout = (2 , 3 ))
674
674
tm .close ()
675
675
676
- with pytest .raises (ValueError ):
676
+ with pytest .raises (ValueError , match = msg ):
677
677
fig , axes = self .plt .subplots (2 , 3 )
678
678
# pass different number of axes from required
679
679
df .plot (subplots = True , ax = axes )
@@ -784,9 +784,9 @@ def test_negative_log(self):
784
784
columns = ["x" , "y" , "z" , "four" ],
785
785
)
786
786
787
- with pytest .raises (ValueError ):
787
+ with pytest .raises (ValueError , match = msg ):
788
788
df .plot .area (logy = True )
789
- with pytest .raises (ValueError ):
789
+ with pytest .raises (ValueError , match = msg ):
790
790
df .plot .area (loglog = True )
791
791
792
792
def _compare_stacked_y_cood (self , normal_lines , stacked_lines ):
@@ -826,7 +826,7 @@ def test_line_area_stacked(self):
826
826
self ._compare_stacked_y_cood (ax1 .lines [2 :], ax2 .lines [2 :])
827
827
828
828
_check_plot_works (mixed_df .plot , stacked = False )
829
- with pytest .raises (ValueError ):
829
+ with pytest .raises (ValueError , match = msg ):
830
830
mixed_df .plot (stacked = True )
831
831
832
832
# Use an index with strictly positive values, preventing
@@ -1153,9 +1153,9 @@ def test_plot_scatter(self):
1153
1153
_check_plot_works (df .plot .scatter , x = "x" , y = "y" )
1154
1154
_check_plot_works (df .plot .scatter , x = 1 , y = 2 )
1155
1155
1156
- with pytest .raises (TypeError ):
1156
+ with pytest .raises (TypeError , match = msg ):
1157
1157
df .plot .scatter (x = "x" )
1158
- with pytest .raises (TypeError ):
1158
+ with pytest .raises (TypeError , match = msg ):
1159
1159
df .plot .scatter (y = "y" )
1160
1160
1161
1161
# GH 6951
@@ -1310,7 +1310,7 @@ def test_plot_scatter_with_c(self):
1310
1310
1311
1311
def test_scatter_colors (self ):
1312
1312
df = DataFrame ({"a" : [1 , 2 , 3 ], "b" : [1 , 2 , 3 ], "c" : [1 , 2 , 3 ]})
1313
- with pytest .raises (TypeError ):
1313
+ with pytest .raises (TypeError , match = msg ):
1314
1314
df .plot .scatter (x = "a" , y = "b" , c = "c" , color = "green" )
1315
1315
1316
1316
default_colors = self ._unpack_cycler (self .plt .rcParams )
@@ -1580,7 +1580,7 @@ def test_boxplot_return_type(self):
1580
1580
index = list (string .ascii_letters [:6 ]),
1581
1581
columns = ["one" , "two" , "three" , "four" ],
1582
1582
)
1583
- with pytest .raises (ValueError ):
1583
+ with pytest .raises (ValueError , match = msg ):
1584
1584
df .plot .box (return_type = "NOTATYPE" )
1585
1585
1586
1586
result = df .plot .box (return_type = "dict" )
@@ -2036,7 +2036,7 @@ def test_line_colors(self):
2036
2036
self ._check_colors (ax .get_lines (), linecolors = custom_colors )
2037
2037
tm .close ()
2038
2038
2039
- with pytest .raises (ValueError ):
2039
+ with pytest .raises (ValueError , match = msg ):
2040
2040
# Color contains shorthand hex value results in ValueError
2041
2041
custom_colors = ["#F00" , "#00F" , "#FF0" , "#000" , "#FFF" ]
2042
2042
# Forced show plot
@@ -2093,7 +2093,7 @@ def test_line_colors_and_styles_subplots(self):
2093
2093
self ._check_colors (ax .get_lines (), linecolors = [c ])
2094
2094
tm .close ()
2095
2095
2096
- with pytest .raises (ValueError ):
2096
+ with pytest .raises (ValueError , match = msg ):
2097
2097
# Color contains shorthand hex value results in ValueError
2098
2098
custom_colors = ["#F00" , "#00F" , "#FF0" , "#000" , "#FFF" ]
2099
2099
# Forced show plot
@@ -2348,7 +2348,7 @@ def _check_colors(bp, box_c, whiskers_c, medians_c, caps_c="k", fliers_c=None):
2348
2348
bp = df .plot .box (color = (0 , 1 , 0 ), sym = "#123456" , return_type = "dict" )
2349
2349
_check_colors (bp , (0 , 1 , 0 ), (0 , 1 , 0 ), (0 , 1 , 0 ), (0 , 1 , 0 ), "#123456" )
2350
2350
2351
- with pytest .raises (ValueError ):
2351
+ with pytest .raises (ValueError , match = msg ):
2352
2352
# Color contains invalid key results in ValueError
2353
2353
df .plot .box (color = dict (boxes = "red" , xxxx = "blue" ))
2354
2354
@@ -2413,12 +2413,12 @@ def test_partially_invalid_plot_data(self):
2413
2413
df = DataFrame (rand (10 , 2 ), dtype = object )
2414
2414
df [np .random .rand (df .shape [0 ]) > 0.5 ] = "a"
2415
2415
for kind in kinds :
2416
- with pytest .raises (TypeError ):
2416
+ with pytest .raises (TypeError , match = msg ):
2417
2417
df .plot (kind = kind )
2418
2418
2419
2419
def test_invalid_kind (self ):
2420
2420
df = DataFrame (randn (10 , 2 ))
2421
- with pytest .raises (ValueError ):
2421
+ with pytest .raises (ValueError , match = msg ):
2422
2422
df .plot (kind = "aasdf" )
2423
2423
2424
2424
@pytest .mark .parametrize (
@@ -2432,14 +2432,14 @@ def test_invalid_kind(self):
2432
2432
def test_invalid_xy_args (self , x , y , lbl ):
2433
2433
# GH 18671, 19699 allows y to be list-like but not x
2434
2434
df = DataFrame ({"A" : [1 , 2 ], "B" : [3 , 4 ], "C" : [5 , 6 ]})
2435
- with pytest .raises (ValueError ):
2435
+ with pytest .raises (ValueError , match = msg ):
2436
2436
df .plot (x = x , y = y , label = lbl )
2437
2437
2438
2438
@pytest .mark .parametrize ("x,y" , [("A" , "B" ), (["A" ], "B" )])
2439
2439
def test_invalid_xy_args_dup_cols (self , x , y ):
2440
2440
# GH 18671, 19699 allows y to be list-like but not x
2441
2441
df = DataFrame ([[1 , 3 , 5 ], [2 , 4 , 6 ]], columns = list ("AAB" ))
2442
- with pytest .raises (ValueError ):
2442
+ with pytest .raises (ValueError , match = msg ):
2443
2443
df .plot (x = x , y = y )
2444
2444
2445
2445
@pytest .mark .parametrize (
@@ -2518,7 +2518,7 @@ def test_allow_cmap(self):
2518
2518
ax = df .plot .hexbin (x = "A" , y = "B" , cmap = "YlGn" )
2519
2519
assert ax .collections [0 ].cmap .name == "YlGn"
2520
2520
2521
- with pytest .raises (TypeError ):
2521
+ with pytest .raises (TypeError , match = msg ):
2522
2522
df .plot .hexbin (x = "A" , y = "B" , cmap = "YlGn" , colormap = "BuGn" )
2523
2523
2524
2524
@pytest .mark .slow
@@ -2528,7 +2528,7 @@ def test_pie_df(self):
2528
2528
columns = ["X" , "Y" , "Z" ],
2529
2529
index = ["a" , "b" , "c" , "d" , "e" ],
2530
2530
)
2531
- with pytest .raises (ValueError ):
2531
+ with pytest .raises (ValueError , match = msg ):
2532
2532
df .plot .pie ()
2533
2533
2534
2534
ax = _check_plot_works (df .plot .pie , y = "Y" )
@@ -2635,11 +2635,11 @@ def test_errorbar_plot(self):
2635
2635
ax = _check_plot_works (s_df .plot , y = "y" , x = "x" , yerr = yerr )
2636
2636
self ._check_has_errorbars (ax , xerr = 0 , yerr = 1 )
2637
2637
2638
- with pytest .raises (ValueError ):
2638
+ with pytest .raises (ValueError , match = msg ):
2639
2639
df .plot (yerr = np .random .randn (11 ))
2640
2640
2641
2641
df_err = DataFrame ({"x" : ["zzz" ] * 12 , "y" : ["zzz" ] * 12 })
2642
- with pytest .raises ((ValueError , TypeError )):
2642
+ with pytest .raises ((ValueError , TypeError ), match = msg ):
2643
2643
df .plot (yerr = df_err )
2644
2644
2645
2645
@pytest .mark .xfail (reason = "Iterator is consumed" , raises = ValueError )
@@ -2731,7 +2731,7 @@ def test_errorbar_asymmetrical(self):
2731
2731
expected_0_0 = err [0 , :, 0 ] * np .array ([- 1 , 1 ])
2732
2732
tm .assert_almost_equal (yerr_0_0 , expected_0_0 )
2733
2733
2734
- with pytest .raises (ValueError ):
2734
+ with pytest .raises (ValueError , match = msg ):
2735
2735
df .plot (yerr = err .T )
2736
2736
2737
2737
tm .close ()
@@ -2923,7 +2923,7 @@ def test_memory_leak(self):
2923
2923
gc .collect ()
2924
2924
for key in results :
2925
2925
# check that every plot was collected
2926
- with pytest .raises (ReferenceError ):
2926
+ with pytest .raises (ReferenceError , match = msg ):
2927
2927
# need to actually access something to get an error
2928
2928
results [key ].lines
2929
2929
@@ -3102,7 +3102,7 @@ def test_df_grid_settings(self):
3102
3102
def test_invalid_colormap (self ):
3103
3103
df = DataFrame (randn (3 , 2 ), columns = ["A" , "B" ])
3104
3104
3105
- with pytest .raises (ValueError ):
3105
+ with pytest .raises (ValueError , match = msg ):
3106
3106
df .plot (colormap = "invalid_colormap" )
3107
3107
3108
3108
def test_plain_axes (self ):
@@ -3268,7 +3268,7 @@ def test_plot_no_rows(self):
3268
3268
3269
3269
def test_plot_no_numeric_data (self ):
3270
3270
df = pd .DataFrame (["a" , "b" , "c" ])
3271
- with pytest .raises (TypeError ):
3271
+ with pytest .raises (TypeError , match = msg ):
3272
3272
df .plot ()
3273
3273
3274
3274
def test_missing_markers_legend (self ):
0 commit comments