DEPR: Add Deprecated warning for timedelta with passed units M and Y by ryankarlos · Pull Request #23264 · pandas-dev/pandas (original) (raw)

@jorisvandenbossche I just tried running this locally and i get an assertion error if I remove check_stacklevel for Timdelta (setting stacklevel = 2 or stacklevel=3 seems to make no difference). Not sure if it will get through travis if i don't set to check_stacklevel=False- i remember experimenting with this in the previous builds which failed.:

../../../anaconda/envs/pandas-dev/lib/python3.7/contextlib.py:119: AssertionError
________________________________ TestTimedeltas.test_unit_m_y_deprecated[M] _________________________________

self = <pandas.tests.scalar.timedelta.test_timedelta.TestTimedeltas object at 0x1c169e02b0>, unit = 'M'

@pytest.mark.skipif(sys.version_info < (3, 5),
                    reason="requires python3.5 or higher")
@pytest.mark.parametrize('unit', ['Y', 'y', 'M'])
def test_unit_m_y_deprecated(self, unit):
    with tm.assert_produces_warning(FutureWarning) as w1:

pandas/tests/scalar/timedelta/test_timedelta.py:387:


self = <contextlib._GeneratorContextManager object at 0x1c169e0438>, type = None, value = None
traceback = None

def __exit__(self, type, value, traceback):
    if type is None:
        try:

E AssertionError: Warning not set with correct stacklevel. File where warning is raised: /Users/ryannazareth/anaconda/envs/pandas-dev/lib/python3.7/site-packages/_pytest/python.py != /Users/ryannazareth/Documents/Python_sprints/pandas-ryankarlos/pandas/tests/scalar/timedelta/test_timedelta.py. Warning message: M and Y units are deprecated and will be removed in a future version.

../../../anaconda/envs/pandas-dev/lib/python3.7/contextlib.py:119: AssertionError
================================== 3 failed, 75 deselected in 0.68 seconds ==================================