Make TimedeltaIndex +/- pd.NaT return TimedeltaIndex by jbrockmendel · Pull Request #19139 · pandas-dev/pandas (original) (raw)
I read your comment. its doesn't make any sense.
Then ask for clarification, buddy. Just repeating the request without acknowledging that I tried to implement and discuss it is pretty discouraging.
Implementing the parameterization you're asking for looks like this:
@pytest.mark.parametrize('box, assert_func', [
(TimedeltaIndex, tm.assert_index_equal),
pytest.param((Series, tm.assert_series_equal),
marks=pytest.mark.xfail(reason='NaT - Series returns NaT'))
])
def test_nat_arithmetic_td64_vector(box, assert_func):
[...]
(Even if it didn't cause an error, this is 5 lines of boilerplate to eliminate a 6 line test.)
python -m pytest pandas/tests/scalar/test_nat.py
then raises at test-collection time:
/usr/local/lib/python2.7/site-packages/_pytest/python.py:832: in parametrize
param.values, argnames))
E ValueError: In "parametrize" the number of values (((<class 'pandas.core.series.Series'>, <function assert_series_equal at 0x10c0a6140>),)) must be equal to the number of names (['box', 'assert_func'])
So the options here are:
- Wait for this to get fixed on pytest's end
- kludge some other boilerplate to avoid needing to use pytest.param here
- Merge as is, at which point I can make a PR that fixes the bug that makes the xfail necessary, and that PR can parametrize the test.