Skip to content

Commit 25d7bd2

Browse files
jbrockmendeljreback
authored andcommitted
TST: collect logical ops tests, use fixtures (#23029)
1 parent 5551bcf commit 25d7bd2

File tree

5 files changed

+582
-586
lines changed

5 files changed

+582
-586
lines changed

pandas/tests/arithmetic/test_timedelta64.py

+8-38
Original file line numberDiff line numberDiff line change
@@ -388,19 +388,11 @@ def test_td64arr_sub_period(self, box, freq):
388388
with pytest.raises(TypeError):
389389
p - idx
390390

391-
@pytest.mark.parametrize('box', [
392-
pd.Index,
393-
Series,
394-
pytest.param(pd.DataFrame,
395-
marks=pytest.mark.xfail(reason="broadcasts along "
396-
"wrong axis",
397-
raises=ValueError,
398-
strict=True))
399-
], ids=lambda x: x.__name__)
400391
@pytest.mark.parametrize('pi_freq', ['D', 'W', 'Q', 'H'])
401392
@pytest.mark.parametrize('tdi_freq', [None, 'H'])
402-
def test_td64arr_sub_pi(self, box, tdi_freq, pi_freq):
393+
def test_td64arr_sub_pi(self, box_df_broadcast_failure, tdi_freq, pi_freq):
403394
# GH#20049 subtracting PeriodIndex should raise TypeError
395+
box = box_df_broadcast_failure
404396
tdi = TimedeltaIndex(['1 hours', '2 hours'], freq=tdi_freq)
405397
dti = Timestamp('2018-03-07 17:16:40') + tdi
406398
pi = dti.to_period(pi_freq)
@@ -529,16 +521,9 @@ def test_td64arr_rsub_int_series_invalid(self, box, tdser):
529521
with pytest.raises(err):
530522
Series([2, 3, 4]) - tdser
531523

532-
@pytest.mark.parametrize('box', [
533-
pd.Index,
534-
Series,
535-
pytest.param(pd.DataFrame,
536-
marks=pytest.mark.xfail(reason="Attempts to broadcast "
537-
"incorrectly",
538-
strict=True, raises=ValueError))
539-
], ids=lambda x: x.__name__)
540-
def test_td64arr_add_intlike(self, box):
524+
def test_td64arr_add_intlike(self, box_df_broadcast_failure):
541525
# GH#19123
526+
box = box_df_broadcast_failure
542527
tdi = TimedeltaIndex(['59 days', '59 days', 'NaT'])
543528
ser = tm.box_expected(tdi, box)
544529
err = TypeError if box is not pd.Index else NullFrequencyError
@@ -706,21 +691,13 @@ def test_td64arr_sub_td64_array(self, box_df_broadcast_failure):
706691
tm.assert_equal(result, expected)
707692

708693
# TODO: parametrize over [add, sub, radd, rsub]?
709-
@pytest.mark.parametrize('box', [
710-
pd.Index,
711-
Series,
712-
pytest.param(pd.DataFrame,
713-
marks=pytest.mark.xfail(reason="Tries to broadcast "
714-
"incorrectly leading "
715-
"to alignment error",
716-
strict=True, raises=ValueError))
717-
], ids=lambda x: x.__name__)
718694
@pytest.mark.parametrize('names', [(None, None, None),
719695
('Egon', 'Venkman', None),
720696
('NCC1701D', 'NCC1701D', 'NCC1701D')])
721-
def test_td64arr_add_sub_tdi(self, box, names):
697+
def test_td64arr_add_sub_tdi(self, box_df_broadcast_failure, names):
722698
# GH#17250 make sure result dtype is correct
723699
# GH#19043 make sure names are propagated correctly
700+
box = box_df_broadcast_failure
724701
tdi = TimedeltaIndex(['0 days', '1 day'], name=names[0])
725702
ser = Series([Timedelta(hours=3), Timedelta(hours=4)], name=names[1])
726703
expected = Series([Timedelta(hours=3), Timedelta(days=1, hours=4)],
@@ -830,19 +807,12 @@ def test_timedelta64_operations_with_DateOffset(self):
830807
td - op(5)
831808
op(5) - td
832809

833-
@pytest.mark.parametrize('box', [
834-
pd.Index,
835-
Series,
836-
pytest.param(pd.DataFrame,
837-
marks=pytest.mark.xfail(reason="Tries to broadcast "
838-
"incorrectly",
839-
strict=True, raises=ValueError))
840-
], ids=lambda x: x.__name__)
841810
@pytest.mark.parametrize('names', [(None, None, None),
842811
('foo', 'bar', None),
843812
('foo', 'foo', 'foo')])
844-
def test_td64arr_add_offset_index(self, names, box):
813+
def test_td64arr_add_offset_index(self, names, box_df_broadcast_failure):
845814
# GH#18849, GH#19744
815+
box = box_df_broadcast_failure
846816
tdi = TimedeltaIndex(['1 days 00:00:00', '3 days 04:00:00'],
847817
name=names[0])
848818
other = pd.Index([pd.offsets.Hour(n=1), pd.offsets.Minute(n=-2)],

0 commit comments

Comments
 (0)