Skip to content

REF: misplaced repr tests #32736

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 1 commit into from
Mar 16, 2020
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
5 changes: 5 additions & 0 deletions pandas/tests/frame/test_repr_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,8 @@ def test_repr_np_nat_with_object(self, arg, box, expected):
# GH 25445
result = repr(box([arg("NaT")], dtype=object))
assert result == expected

def test_frame_datetime64_pre1900_repr(self):
df = DataFrame({"year": date_range("1/1/1700", periods=50, freq="A-DEC")})
# it works!
repr(df)
5 changes: 0 additions & 5 deletions pandas/tests/frame/test_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ def test_frame_append_datetime64_column(self):
df["A"] = rng
assert np.issubdtype(df["A"].dtype, np.dtype("M8[ns]"))

def test_frame_datetime64_pre1900_repr(self):
df = DataFrame({"year": date_range("1/1/1700", periods=50, freq="A-DEC")})
# it works!
repr(df)

def test_frame_append_datetime64_col_other_units(self):
n = 100

Expand Down
9 changes: 5 additions & 4 deletions pandas/tests/series/indexing/test_alter_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,9 +523,9 @@ def test_drop_unique_and_non_unique_index(
],
)
def test_drop_exception_raised(data, index, drop_labels, axis, error_type, error_desc):

ser = Series(data, index=index)
with pytest.raises(error_type, match=error_desc):
Series(data, index=index).drop(drop_labels, axis=axis)
ser.drop(drop_labels, axis=axis)


def test_drop_with_ignore_errors():
Expand Down Expand Up @@ -565,6 +565,7 @@ def test_drop_empty_list(index, drop_labels):
)
def test_drop_non_empty_list(data, index, drop_labels):
# GH 21494 and GH 16877
dtype = object if data is None else None
ser = pd.Series(data=data, index=index, dtype=dtype)
with pytest.raises(KeyError, match="not found in axis"):
dtype = object if data is None else None
pd.Series(data=data, index=index, dtype=dtype).drop(drop_labels)
ser.drop(drop_labels)
19 changes: 19 additions & 0 deletions pandas/tests/series/test_repr.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,25 @@ def test_index_repr_in_frame_with_nan(self):

assert repr(s) == exp

def test_format_pre_1900_dates(self):
rng = date_range("1/1/1850", "1/1/1950", freq="A-DEC")
rng.format()
ts = Series(1, index=rng)
repr(ts)

def test_series_repr_nat(self):
series = Series([0, 1000, 2000, pd.NaT.value], dtype="M8[ns]")

result = repr(series)
expected = (
"0 1970-01-01 00:00:00.000000\n"
"1 1970-01-01 00:00:00.000001\n"
"2 1970-01-01 00:00:00.000002\n"
"3 NaT\n"
"dtype: datetime64[ns]"
)
assert result == expected


class TestCategoricalRepr:
def test_categorical_repr_unicode(self):
Expand Down
21 changes: 0 additions & 21 deletions pandas/tests/series/test_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import numpy as np

from pandas._libs.tslib import iNaT

import pandas as pd
from pandas import DataFrame, DatetimeIndex, Series, date_range, timedelta_range
import pandas._testing as tm
Expand Down Expand Up @@ -88,19 +86,6 @@ def test_series_ctor_datetime64(self):
series = Series(dates)
assert np.issubdtype(series.dtype, np.dtype("M8[ns]"))

def test_series_repr_nat(self):
series = Series([0, 1000, 2000, iNaT], dtype="M8[ns]")

result = repr(series)
expected = (
"0 1970-01-01 00:00:00.000000\n"
"1 1970-01-01 00:00:00.000001\n"
"2 1970-01-01 00:00:00.000002\n"
"3 NaT\n"
"dtype: datetime64[ns]"
)
assert result == expected

def test_promote_datetime_date(self):
rng = date_range("1/1/2000", periods=20)
ts = Series(np.random.randn(20), index=rng)
Expand All @@ -124,12 +109,6 @@ def test_promote_datetime_date(self):
expected = rng.get_indexer(ts_slice.index)
tm.assert_numpy_array_equal(result, expected)

def test_format_pre_1900_dates(self):
rng = date_range("1/1/1850", "1/1/1950", freq="A-DEC")
rng.format()
ts = Series(1, index=rng)
repr(ts)

def test_groupby_count_dateparseerror(self):
dr = date_range(start="1/1/2012", freq="5min", periods=10)

Expand Down