Skip to content

Commit

Permalink
misplaced tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockmendel committed Nov 1, 2023
1 parent 76eebff commit e6c9f11
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
16 changes: 16 additions & 0 deletions pandas/tests/frame/test_repr.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
Categorical,
CategoricalIndex,
DataFrame,
IntervalIndex,
MultiIndex,
NaT,
PeriodIndex,
Expand Down Expand Up @@ -307,6 +308,21 @@ def test_latex_repr(self):
# GH 12182
assert df._repr_latex_() is None

def test_repr_with_datetimeindex(self):
df = DataFrame({"A": [1, 2, 3]}, index=date_range("2000", periods=3))
result = repr(df)
expected = " A\n2000-01-01 1\n2000-01-02 2\n2000-01-03 3"
assert result == expected

def test_repr_with_intervalindex(self):
# https://github.com/pandas-dev/pandas/pull/24134/files
df = DataFrame(
{"A": [1, 2, 3, 4]}, index=IntervalIndex.from_breaks([0, 1, 2, 3, 4])
)
result = repr(df)
expected = " A\n(0, 1] 1\n(1, 2] 2\n(2, 3] 3\n(3, 4] 4"
assert result == expected

def test_repr_with_categorical_index(self):
df = DataFrame({"A": [1, 2, 3]}, index=CategoricalIndex(["a", "b", "c"]))
result = repr(df)
Expand Down
10 changes: 1 addition & 9 deletions pandas/tests/indexes/interval/test_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,7 @@


class TestIntervalIndexRendering:
def test_frame_repr(self):
# https://github.com/pandas-dev/pandas/pull/24134/files
df = DataFrame(
{"A": [1, 2, 3, 4]}, index=IntervalIndex.from_breaks([0, 1, 2, 3, 4])
)
result = repr(df)
expected = " A\n(0, 1] 1\n(1, 2] 2\n(2, 3] 3\n(3, 4] 4"
assert result == expected

# TODO: this is a test for DataFrame/Series, not IntervalIndex
@pytest.mark.parametrize(
"constructor,expected",
[
Expand Down
7 changes: 1 addition & 6 deletions pandas/tests/indexes/period/test_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,6 @@ def test_format_empty(self):
with tm.assert_produces_warning(FutureWarning, match=msg):
assert empty_idx.format(name=True) == [""]

def test_frame_repr(self):
df = pd.DataFrame({"A": [1, 2, 3]}, index=pd.date_range("2000", periods=3))
result = repr(df)
expected = " A\n2000-01-01 1\n2000-01-02 2\n2000-01-03 3"
assert result == expected

@pytest.mark.parametrize("method", ["__repr__", "__str__"])
def test_representation(self, method):
# GH#7601
Expand Down Expand Up @@ -118,6 +112,7 @@ def test_representation(self, method):
result = getattr(idx, method)()
assert result == expected

# TODO: These are Series.__repr__ tests
def test_representation_to_series(self):
# GH#10971
idx1 = PeriodIndex([], freq="D")
Expand Down
1 change: 1 addition & 0 deletions pandas/tests/indexes/timedeltas/test_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def test_representation(self, method):
result = getattr(idx, method)()
assert result == expected

# TODO: this is a Series.__repr__ test
def test_representation_to_series(self):
idx1 = TimedeltaIndex([], freq="D")
idx2 = TimedeltaIndex(["1 days"], freq="D")
Expand Down

0 comments on commit e6c9f11

Please sign in to comment.