@@ -32,23 +32,34 @@ def test_constructor(self, which):
32
32
c = o .rolling
33
33
34
34
# valid
35
+ c (0 )
35
36
c (window = 2 )
36
37
c (window = 2 , min_periods = 1 )
37
38
c (window = 2 , min_periods = 1 , center = True )
38
39
c (window = 2 , min_periods = 1 , center = False )
39
40
40
41
# GH 13383
41
- with pytest .raises (ValueError ):
42
- c (0 )
42
+
43
+ msg = "window must be non-negative"
44
+
45
+ with pytest .raises (ValueError , match = msg ):
43
46
c (- 1 )
44
47
45
48
# not valid
46
49
for w in [2.0 , "foo" , np .array ([2 ])]:
47
- with pytest .raises (ValueError ):
50
+ msg = (
51
+ "window must be an integer|"
52
+ "passed window foo is not compatible with a datetimelike index"
53
+ )
54
+ with pytest .raises (ValueError , match = msg ):
48
55
c (window = w )
49
- with pytest .raises (ValueError ):
56
+
57
+ msg = "min_periods must be an integer"
58
+ with pytest .raises (ValueError , match = msg ):
50
59
c (window = 2 , min_periods = w )
51
- with pytest .raises (ValueError ):
60
+
61
+ msg = "center must be a boolean"
62
+ with pytest .raises (ValueError , match = msg ):
52
63
c (window = 2 , min_periods = 1 , center = w )
53
64
54
65
@td .skip_if_no_scipy
@@ -57,7 +68,10 @@ def test_constructor_with_win_type(self, which):
57
68
# GH 13383
58
69
o = getattr (self , which )
59
70
c = o .rolling
60
- with pytest .raises (ValueError ):
71
+
72
+ msg = "window must be > 0"
73
+
74
+ with pytest .raises (ValueError , match = msg ):
61
75
c (- 1 , win_type = "boxcar" )
62
76
63
77
@pytest .mark .parametrize ("window" , [timedelta (days = 3 ), pd .Timedelta (days = 3 )])
@@ -113,7 +127,10 @@ def test_numpy_compat(self, method):
113
127
def test_closed (self ):
114
128
df = DataFrame ({"A" : [0 , 1 , 2 , 3 , 4 ]})
115
129
# closed only allowed for datetimelike
116
- with pytest .raises (ValueError ):
130
+
131
+ msg = "closed only implemented for datetimelike and offset based windows"
132
+
133
+ with pytest .raises (ValueError , match = msg ):
117
134
df .rolling (window = 3 , closed = "neither" )
118
135
119
136
@pytest .mark .parametrize ("closed" , ["neither" , "left" ])
@@ -296,7 +313,10 @@ def test_iter_raises(self, klass):
296
313
# https://github.com/pandas-dev/pandas/issues/11704
297
314
# Iteration over a Window
298
315
obj = klass ([1 , 2 , 3 , 4 ])
299
- with pytest .raises (NotImplementedError ):
316
+
317
+ msg = "See issue #11704 https://github.com/pandas-dev/pandas/issues/11704"
318
+
319
+ with pytest .raises (NotImplementedError , match = msg ):
300
320
iter (obj .rolling (2 ))
301
321
302
322
def test_rolling_axis_sum (self , axis_frame ):
0 commit comments