Skip to content

Commit be30d0a

Browse files
authored
TST: check freq in assert_equal (#33812)
1 parent 71d6105 commit be30d0a

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

pandas/_testing.py

+2
Original file line numberDiff line numberDiff line change
@@ -1448,6 +1448,8 @@ def assert_equal(left, right, **kwargs):
14481448

14491449
if isinstance(left, pd.Index):
14501450
assert_index_equal(left, right, **kwargs)
1451+
if isinstance(left, (pd.DatetimeIndex, pd.TimedeltaIndex)):
1452+
assert left.freq == right.freq, (left.freq, right.freq)
14511453
elif isinstance(left, pd.Series):
14521454
assert_series_equal(left, right, **kwargs)
14531455
elif isinstance(left, pd.DataFrame):

pandas/tests/arithmetic/test_datetime64.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,7 @@ def test_dt64arr_add_sub_td64ndarray(self, tz_naive_fixture, box_with_array):
897897
)
898898
def test_dt64arr_sub_dtscalar(self, box_with_array, ts):
899899
# GH#8554, GH#22163 DataFrame op should _not_ return dt64 dtype
900-
idx = pd.date_range("2013-01-01", periods=3)
900+
idx = pd.date_range("2013-01-01", periods=3)._with_freq(None)
901901
idx = tm.box_expected(idx, box_with_array)
902902

903903
expected = pd.TimedeltaIndex(["0 Days", "1 Day", "2 Days"])
@@ -912,7 +912,7 @@ def test_dt64arr_sub_datetime64_not_ns(self, box_with_array):
912912
dt64 = np.datetime64("2013-01-01")
913913
assert dt64.dtype == "datetime64[D]"
914914

915-
dti = pd.date_range("20130101", periods=3)
915+
dti = pd.date_range("20130101", periods=3)._with_freq(None)
916916
dtarr = tm.box_expected(dti, box_with_array)
917917

918918
expected = pd.TimedeltaIndex(["0 Days", "1 Day", "2 Days"])
@@ -926,6 +926,7 @@ def test_dt64arr_sub_datetime64_not_ns(self, box_with_array):
926926

927927
def test_dt64arr_sub_timestamp(self, box_with_array):
928928
ser = pd.date_range("2014-03-17", periods=2, freq="D", tz="US/Eastern")
929+
ser = ser._with_freq(None)
929930
ts = ser[0]
930931

931932
ser = tm.box_expected(ser, box_with_array)

0 commit comments

Comments
 (0)