Skip to content

Commit a926bce

Browse files
authored
TST: move index tests to correct files (#27045) (#42952)
1 parent 93af2f0 commit a926bce

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

pandas/tests/tseries/offsets/test_business_month.py

+24
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import pytest
99

10+
import pandas as pd
1011
from pandas.tests.tseries.offsets.common import (
1112
Base,
1213
assert_is_on_offset,
@@ -19,6 +20,29 @@
1920
)
2021

2122

23+
@pytest.mark.parametrize("n", [-2, 1])
24+
@pytest.mark.parametrize(
25+
"cls",
26+
[
27+
BMonthBegin,
28+
BMonthEnd,
29+
],
30+
)
31+
def test_apply_index(cls, n):
32+
offset = cls(n=n)
33+
rng = pd.date_range(start="1/1/2000", periods=100000, freq="T")
34+
ser = pd.Series(rng)
35+
36+
res = rng + offset
37+
assert res.freq is None # not retained
38+
assert res[0] == rng[0] + offset
39+
assert res[-1] == rng[-1] + offset
40+
res2 = ser + offset
41+
# apply_index is only for indexes, not series, so no res2_v2
42+
assert res2.iloc[0] == ser.iloc[0] + offset
43+
assert res2.iloc[-1] == ser.iloc[-1] + offset
44+
45+
2246
class TestBMonthBegin(Base):
2347
_offset = BMonthBegin
2448

pandas/tests/tseries/offsets/test_yqm_offsets.py renamed to pandas/tests/tseries/offsets/test_index.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
"""
2-
Tests for Year, Quarter, and Month-based DateOffset subclasses
2+
Tests for offset behavior with indices.
33
"""
44
import pytest
55

6-
import pandas as pd
6+
from pandas import (
7+
Series,
8+
date_range,
9+
)
710

811
from pandas.tseries.offsets import (
912
BMonthBegin,
@@ -41,8 +44,8 @@
4144
)
4245
def test_apply_index(cls, n):
4346
offset = cls(n=n)
44-
rng = pd.date_range(start="1/1/2000", periods=100000, freq="T")
45-
ser = pd.Series(rng)
47+
rng = date_range(start="1/1/2000", periods=100000, freq="T")
48+
ser = Series(rng)
4649

4750
res = rng + offset
4851
assert res.freq is None # not retained

0 commit comments

Comments
 (0)