Skip to content

TST: move index tests to correct files (#27045) #42952

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions pandas/tests/tseries/offsets/test_business_month.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import pytest

import pandas as pd
from pandas.tests.tseries.offsets.common import (
Base,
assert_is_on_offset,
Expand All @@ -19,6 +20,29 @@
)


@pytest.mark.parametrize("n", [-2, 1])
@pytest.mark.parametrize(
"cls",
[
BMonthBegin,
BMonthEnd,
],
)
def test_apply_index(cls, n):
offset = cls(n=n)
rng = pd.date_range(start="1/1/2000", periods=100000, freq="T")
ser = pd.Series(rng)

res = rng + offset
assert res.freq is None # not retained
assert res[0] == rng[0] + offset
assert res[-1] == rng[-1] + offset
res2 = ser + offset
# apply_index is only for indexes, not series, so no res2_v2
assert res2.iloc[0] == ser.iloc[0] + offset
assert res2.iloc[-1] == ser.iloc[-1] + offset


class TestBMonthBegin(Base):
_offset = BMonthBegin

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
"""
Tests for Year, Quarter, and Month-based DateOffset subclasses
Tests for offset behavior with indices.
"""
import pytest

import pandas as pd
from pandas import (
Series,
date_range,
)

from pandas.tseries.offsets import (
BMonthBegin,
Expand Down Expand Up @@ -41,8 +44,8 @@
)
def test_apply_index(cls, n):
offset = cls(n=n)
rng = pd.date_range(start="1/1/2000", periods=100000, freq="T")
ser = pd.Series(rng)
rng = date_range(start="1/1/2000", periods=100000, freq="T")
ser = Series(rng)

res = rng + offset
assert res.freq is None # not retained
Expand Down