@@ -118,27 +118,27 @@ def test_parr_cmp_pi_mismatched_freq_raises(self, freq, box_df_fail):
118
118
base = tm .box_expected (base , box )
119
119
120
120
msg = "Input has different freq=A-DEC from "
121
- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
121
+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
122
122
base <= Period ('2011' , freq = 'A' )
123
123
124
- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
124
+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
125
125
Period ('2011' , freq = 'A' ) >= base
126
126
127
127
# TODO: Could parametrize over boxes for idx?
128
128
idx = PeriodIndex (['2011' , '2012' , '2013' , '2014' ], freq = 'A' )
129
- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
129
+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
130
130
base <= idx
131
131
132
132
# Different frequency
133
133
msg = "Input has different freq=4M from "
134
- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
134
+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
135
135
base <= Period ('2011' , freq = '4M' )
136
136
137
- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
137
+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
138
138
Period ('2011' , freq = '4M' ) >= base
139
139
140
140
idx = PeriodIndex (['2011' , '2012' , '2013' , '2014' ], freq = '4M' )
141
- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
141
+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
142
142
base <= idx
143
143
144
144
@pytest .mark .parametrize ('freq' , ['M' , '2M' , '3M' ])
@@ -190,10 +190,10 @@ def test_pi_cmp_nat_mismatched_freq_raises(self, freq):
190
190
191
191
diff = PeriodIndex (['2011-02' , '2011-01' , '2011-04' , 'NaT' ], freq = '4M' )
192
192
msg = "Input has different freq=4M from PeriodIndex"
193
- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
193
+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
194
194
idx1 > diff
195
195
196
- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
196
+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
197
197
idx1 == diff
198
198
199
199
# TODO: De-duplicate with test_pi_cmp_nat
@@ -708,13 +708,13 @@ def test_pi_add_sub_timedeltalike_freq_mismatch_daily(self, not_daily):
708
708
other = not_daily
709
709
rng = pd .period_range ('2014-05-01' , '2014-05-15' , freq = 'D' )
710
710
msg = 'Input has different freq(=.+)? from Period.*?\\ (freq=D\\ )'
711
- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
711
+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
712
712
rng + other
713
- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
713
+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
714
714
rng += other
715
- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
715
+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
716
716
rng - other
717
- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
717
+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
718
718
rng -= other
719
719
720
720
def test_pi_add_iadd_timedeltalike_hourly (self , two_hours ):
@@ -734,10 +734,10 @@ def test_pi_add_timedeltalike_mismatched_freq_hourly(self, not_hourly):
734
734
rng = pd .period_range ('2014-01-01 10:00' , '2014-01-05 10:00' , freq = 'H' )
735
735
msg = 'Input has different freq(=.+)? from Period.*?\\ (freq=H\\ )'
736
736
737
- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
737
+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
738
738
rng + other
739
739
740
- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
740
+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
741
741
rng += other
742
742
743
743
def test_pi_sub_isub_timedeltalike_hourly (self , two_hours ):
@@ -768,13 +768,13 @@ def test_pi_add_sub_timedeltalike_freq_mismatch_annual(self,
768
768
rng = pd .period_range ('2014' , '2024' , freq = 'A' )
769
769
msg = ('Input has different freq(=.+)? '
770
770
'from Period.*?\\ (freq=A-DEC\\ )' )
771
- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
771
+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
772
772
rng + other
773
- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
773
+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
774
774
rng += other
775
- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
775
+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
776
776
rng - other
777
- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
777
+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
778
778
rng -= other
779
779
780
780
def test_pi_add_iadd_timedeltalike_M (self ):
@@ -792,13 +792,13 @@ def test_pi_add_sub_timedeltalike_freq_mismatch_monthly(self,
792
792
other = mismatched_freq
793
793
rng = pd .period_range ('2014-01' , '2016-12' , freq = 'M' )
794
794
msg = 'Input has different freq(=.+)? from Period.*?\\ (freq=M\\ )'
795
- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
795
+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
796
796
rng + other
797
- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
797
+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
798
798
rng += other
799
- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
799
+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
800
800
rng - other
801
- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
801
+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
802
802
rng -= other
803
803
804
804
def test_parr_add_sub_td64_nat (self , box ):
@@ -907,14 +907,14 @@ def test_pi_ops_errors(self, ng, box_with_period):
907
907
obj = tm .box_expected (idx , box_with_period )
908
908
909
909
msg = r"unsupported operand type\(s\)"
910
- with tm . assert_raises_regex (TypeError , msg ):
910
+ with pytest . raises (TypeError , match = msg ):
911
911
obj + ng
912
912
913
913
with pytest .raises (TypeError ):
914
914
# error message differs between PY2 and 3
915
915
ng + obj
916
916
917
- with tm . assert_raises_regex (TypeError , msg ):
917
+ with pytest . raises (TypeError , match = msg ):
918
918
obj - ng
919
919
920
920
with pytest .raises (TypeError ):
@@ -1009,13 +1009,13 @@ def test_pi_offset_errors(self):
1009
1009
# from Period
1010
1010
msg = r"Input has different freq from Period.*?\(freq=D\)"
1011
1011
for obj in [idx , ser ]:
1012
- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
1012
+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
1013
1013
obj + pd .offsets .Hour (2 )
1014
1014
1015
- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
1015
+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
1016
1016
pd .offsets .Hour (2 ) + obj
1017
1017
1018
- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
1018
+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
1019
1019
obj - pd .offsets .Hour (2 )
1020
1020
1021
1021
def test_pi_sub_period (self ):
0 commit comments