@@ -118,27 +118,27 @@ def test_parr_cmp_pi_mismatched_freq_raises(self, freq, box_df_fail):
118118 base = tm .box_expected (base , box )
119119
120120 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 ):
122122 base <= Period ('2011' , freq = 'A' )
123123
124- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
124+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
125125 Period ('2011' , freq = 'A' ) >= base
126126
127127 # TODO: Could parametrize over boxes for idx?
128128 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 ):
130130 base <= idx
131131
132132 # Different frequency
133133 msg = "Input has different freq=4M from "
134- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
134+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
135135 base <= Period ('2011' , freq = '4M' )
136136
137- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
137+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
138138 Period ('2011' , freq = '4M' ) >= base
139139
140140 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 ):
142142 base <= idx
143143
144144 @pytest .mark .parametrize ('freq' , ['M' , '2M' , '3M' ])
@@ -190,10 +190,10 @@ def test_pi_cmp_nat_mismatched_freq_raises(self, freq):
190190
191191 diff = PeriodIndex (['2011-02' , '2011-01' , '2011-04' , 'NaT' ], freq = '4M' )
192192 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 ):
194194 idx1 > diff
195195
196- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
196+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
197197 idx1 == diff
198198
199199 # TODO: De-duplicate with test_pi_cmp_nat
@@ -708,13 +708,13 @@ def test_pi_add_sub_timedeltalike_freq_mismatch_daily(self, not_daily):
708708 other = not_daily
709709 rng = pd .period_range ('2014-05-01' , '2014-05-15' , freq = 'D' )
710710 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 ):
712712 rng + other
713- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
713+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
714714 rng += other
715- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
715+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
716716 rng - other
717- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
717+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
718718 rng -= other
719719
720720 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):
734734 rng = pd .period_range ('2014-01-01 10:00' , '2014-01-05 10:00' , freq = 'H' )
735735 msg = 'Input has different freq(=.+)? from Period.*?\\ (freq=H\\ )'
736736
737- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
737+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
738738 rng + other
739739
740- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
740+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
741741 rng += other
742742
743743 def test_pi_sub_isub_timedeltalike_hourly (self , two_hours ):
@@ -768,13 +768,13 @@ def test_pi_add_sub_timedeltalike_freq_mismatch_annual(self,
768768 rng = pd .period_range ('2014' , '2024' , freq = 'A' )
769769 msg = ('Input has different freq(=.+)? '
770770 'from Period.*?\\ (freq=A-DEC\\ )' )
771- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
771+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
772772 rng + other
773- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
773+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
774774 rng += other
775- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
775+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
776776 rng - other
777- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
777+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
778778 rng -= other
779779
780780 def test_pi_add_iadd_timedeltalike_M (self ):
@@ -792,13 +792,13 @@ def test_pi_add_sub_timedeltalike_freq_mismatch_monthly(self,
792792 other = mismatched_freq
793793 rng = pd .period_range ('2014-01' , '2016-12' , freq = 'M' )
794794 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 ):
796796 rng + other
797- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
797+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
798798 rng += other
799- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
799+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
800800 rng - other
801- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
801+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
802802 rng -= other
803803
804804 def test_parr_add_sub_td64_nat (self , box ):
@@ -907,14 +907,14 @@ def test_pi_ops_errors(self, ng, box_with_period):
907907 obj = tm .box_expected (idx , box_with_period )
908908
909909 msg = r"unsupported operand type\(s\)"
910- with tm . assert_raises_regex (TypeError , msg ):
910+ with pytest . raises (TypeError , match = msg ):
911911 obj + ng
912912
913913 with pytest .raises (TypeError ):
914914 # error message differs between PY2 and 3
915915 ng + obj
916916
917- with tm . assert_raises_regex (TypeError , msg ):
917+ with pytest . raises (TypeError , match = msg ):
918918 obj - ng
919919
920920 with pytest .raises (TypeError ):
@@ -1009,13 +1009,13 @@ def test_pi_offset_errors(self):
10091009 # from Period
10101010 msg = r"Input has different freq from Period.*?\(freq=D\)"
10111011 for obj in [idx , ser ]:
1012- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
1012+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
10131013 obj + pd .offsets .Hour (2 )
10141014
1015- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
1015+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
10161016 pd .offsets .Hour (2 ) + obj
10171017
1018- with tm . assert_raises_regex (period .IncompatibleFrequency , msg ):
1018+ with pytest . raises (period .IncompatibleFrequency , match = msg ):
10191019 obj - pd .offsets .Hour (2 )
10201020
10211021 def test_pi_sub_period (self ):
0 commit comments