diff --git a/pandas/tests/generic/test_series.py b/pandas/tests/generic/test_series.py index 388bb8e3f636d..bfdfd6d319b3f 100644 --- a/pandas/tests/generic/test_series.py +++ b/pandas/tests/generic/test_series.py @@ -176,6 +176,9 @@ def finalize(self, other, method=None, **kwargs): Series._metadata = _metadata Series.__finalize__ = _finalize # FIXME: use monkeypatch + +class TestSeries2: + # Separating off because it doesnt rely on parent class @pytest.mark.parametrize( "s", [ @@ -196,26 +199,6 @@ def test_datetime_shift_always_copy(self, move_by_freq): assert s.shift(freq=move_by_freq) is not s -class TestSeries2: - # moved from Generic - def test_get_default(self): - - # GH#7725 - d0 = ["a", "b", "c", "d"] - d1 = np.arange(4, dtype="int64") - others = ["e", 10] - - for data, index in ((d0, d1), (d1, d0)): - s = Series(data, index=index) - for i, d in zip(index, data): - assert s.get(i) == d - assert s.get(i, d) == d - assert s.get(i, "z") == d - for other in others: - assert s.get(other, "z") == "z" - assert s.get(other, other) == other - - class TestToXArray: @pytest.mark.skipif( not _XARRAY_INSTALLED diff --git a/pandas/tests/series/indexing/test_get.py b/pandas/tests/series/indexing/test_get.py index 438b61ed203a3..5847141a44ef5 100644 --- a/pandas/tests/series/indexing/test_get.py +++ b/pandas/tests/series/indexing/test_get.py @@ -132,3 +132,20 @@ def test_get_nan_multiple(): idx = [np.nan, np.nan] assert s.get(idx) is None + + +def test_get_with_default(): + # GH#7725 + d0 = ["a", "b", "c", "d"] + d1 = np.arange(4, dtype="int64") + others = ["e", 10] + + for data, index in ((d0, d1), (d1, d0)): + s = Series(data, index=index) + for i, d in zip(index, data): + assert s.get(i) == d + assert s.get(i, d) == d + assert s.get(i, "z") == d + for other in others: + assert s.get(other, "z") == "z" + assert s.get(other, other) == other diff --git a/pandas/tests/series/test_timeseries.py b/pandas/tests/series/test_timeseries.py index 563cfa57c9214..5c58ead1ef98d 100644 --- a/pandas/tests/series/test_timeseries.py +++ b/pandas/tests/series/test_timeseries.py @@ -7,17 +7,6 @@ import pandas._testing as tm -def _simple_ts(start, end, freq="D"): - rng = date_range(start, end, freq=freq) - return Series(np.random.randn(len(rng)), index=rng) - - -def assert_range_equal(left, right): - assert left.equals(right) - assert left.freq == right.freq - assert left.tz == right.tz - - class TestTimeSeries: def test_autocorr(self, datetime_series): # Just run the function @@ -72,8 +61,8 @@ def test_contiguous_boolean_preserve_freq(self): masked = rng[mask] expected = rng[10:20] - assert expected.freq is not None - assert_range_equal(masked, expected) + assert expected.freq == rng.freq + tm.assert_index_equal(masked, expected) mask[22] = True masked = rng[mask]