Skip to content

Commit 5c35afe

Browse files
committed
Add two more parameters to the test
1 parent 612c244 commit 5c35afe

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

pandas/tests/arithmetic/test_datetime64.py

+22-11
Original file line numberDiff line numberDiff line change
@@ -1435,27 +1435,38 @@ def test_dt64arr_add_sub_offset_ndarray(self, tz_naive_fixture,
14351435
expected = tm.box_expected(expected, box_with_array)
14361436
tm.assert_equal(res, expected)
14371437

1438+
@pytest.mark.parametrize("box", [pd.Index, pd.Series, pd.DataFrame])
14381439
@pytest.mark.parametrize("op, offset, exp", [
14391440
('__add__', pd.DateOffset(months=3, days=10),
1440-
DatetimeIndex([Timestamp('2014-04-11'), Timestamp('2015-04-11'),
1441-
Timestamp('2016-04-11'), Timestamp('2017-04-11')])),
1441+
[Timestamp('2014-04-11'), Timestamp('2015-04-11'),
1442+
Timestamp('2016-04-11'), Timestamp('2017-04-11')]),
14421443
('__add__', pd.DateOffset(months=3),
1443-
DatetimeIndex([Timestamp('2014-04-01'), Timestamp('2015-04-01'),
1444-
Timestamp('2016-04-01'), Timestamp('2017-04-01')])),
1444+
[Timestamp('2014-04-01'), Timestamp('2015-04-01'),
1445+
Timestamp('2016-04-01'), Timestamp('2017-04-01')]),
14451446
('__sub__', pd.DateOffset(months=3, days=10),
1446-
DatetimeIndex([Timestamp('2013-09-21'), Timestamp('2014-09-21'),
1447-
Timestamp('2015-09-21'), Timestamp('2016-09-21')])),
1447+
[Timestamp('2013-09-21'), Timestamp('2014-09-21'),
1448+
Timestamp('2015-09-21'), Timestamp('2016-09-21')]),
14481449
('__sub__', pd.DateOffset(months=3),
1449-
DatetimeIndex([Timestamp('2013-10-01'), Timestamp('2014-10-01'),
1450-
Timestamp('2015-10-01'), Timestamp('2016-10-01')]))
1450+
[Timestamp('2013-10-01'), Timestamp('2014-10-01'),
1451+
Timestamp('2015-10-01'), Timestamp('2016-10-01')])
14511452
14521453
])
1453-
def test_dti_add_sub_nonzero_mth_offset(self, op, offset, exp):
1454+
def test_dti_add_sub_nonzero_mth_offset(self, op, offset, exp,
1455+
tz_aware_fixture,
1456+
box):
14541457
# GH 26258
1455-
date = date_range(start='01 Jan 2014', end='01 Jan 2017', freq='AS')
1458+
tz = tz_aware_fixture
1459+
date = date_range(start='01 Jan 2014', end='01 Jan 2017', freq='AS',
1460+
tz=tz)
1461+
date = (tm.box_expected(date, box) if box is not pd.DataFrame
1462+
else tm.box_expected(date, box, False))
14561463
mth = getattr(date, op)
14571464
result = mth(offset)
1458-
tm.assert_equal(result, exp)
1465+
1466+
expected = pd.Index(exp, tz=tz)
1467+
expected = (tm.box_expected(expected, box) if box is not pd.DataFrame
1468+
else tm.box_expected(expected, box, False))
1469+
tm.assert_equal(result, expected)
14591470

14601471

14611472
class TestDatetime64OverflowHandling:

0 commit comments

Comments
 (0)