From 2e364678893d277ce061ad0cb6e57d6de61c0a9a Mon Sep 17 00:00:00 2001 From: Martin Winkel Date: Tue, 22 Oct 2019 14:03:04 +0200 Subject: [PATCH 1/3] Remove TestData from series-tests test_repr.py * Replaced TestData usage in pandas/tests/series/test_repr.py with fixtures --- pandas/tests/series/test_repr.py | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/pandas/tests/series/test_repr.py b/pandas/tests/series/test_repr.py index 3c6da304dd68d..5b0323b02f3cb 100644 --- a/pandas/tests/series/test_repr.py +++ b/pandas/tests/series/test_repr.py @@ -17,10 +17,8 @@ from pandas.core.index import MultiIndex import pandas.util.testing as tm -from .common import TestData - -class TestSeriesRepr(TestData): +class TestSeriesRepr: def test_multilevel_name_print(self): index = MultiIndex( levels=[["foo", "bar", "baz", "qux"], ["one", "two", "three"]], @@ -67,24 +65,24 @@ def test_name_printing(self): s = Series(index=date_range("20010101", "20020101"), name="test") assert "Name: test" in repr(s) - def test_repr(self): - str(self.ts) - str(self.series) - str(self.series.astype(int)) - str(self.objSeries) + def test_repr(self, datetime_series, string_series, object_series, empty_series): + str(datetime_series) + str(string_series) + str(string_series.astype(int)) + str(object_series) str(Series(tm.randn(1000), index=np.arange(1000))) str(Series(tm.randn(1000), index=np.arange(1000, 0, step=-1))) # empty - str(self.empty) + str(empty_series) # with NaNs - self.series[5:7] = np.NaN - str(self.series) + string_series[5:7] = np.NaN + str(string_series) # with Nones - ots = self.ts.astype("O") + ots = datetime_series.astype("O") ots[::2] = None repr(ots) @@ -102,8 +100,8 @@ def test_repr(self): ("\u03B1", "\u03B2", "\u03B3"), ("\u03B1", "bar"), ]: - self.series.name = name - repr(self.series) + string_series.name = name + repr(string_series) biggie = Series( tm.randn(1000), index=np.arange(1000), name=("foo", "bar", "baz") From 684fed77d21eabbcbe595548294703f1080120cd Mon Sep 17 00:00:00 2001 From: Martin Winkel Date: Tue, 22 Oct 2019 15:22:05 +0200 Subject: [PATCH 2/3] added empty series fixture --- pandas/tests/series/conftest.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pandas/tests/series/conftest.py b/pandas/tests/series/conftest.py index 18d3c87a01f87..dc778b96edb99 100644 --- a/pandas/tests/series/conftest.py +++ b/pandas/tests/series/conftest.py @@ -1,5 +1,6 @@ import pytest +import pandas as pd import pandas.util.testing as tm @@ -31,3 +32,11 @@ def object_series(): s = tm.makeObjectSeries() s.name = "objects" return s + + +@pytest.fixture +def empty_series(): + """ + Fixture for Series that is empty + """ + return pd.Series([], index=[]) From 4460c2147f6bc7ee24c8e70aff2d29682c34efb1 Mon Sep 17 00:00:00 2001 From: Martin Winkel Date: Wed, 23 Oct 2019 15:27:36 +0200 Subject: [PATCH 3/3] removed empty_series fixture and it's usage --- pandas/tests/series/conftest.py | 9 --------- pandas/tests/series/test_repr.py | 4 ++-- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/pandas/tests/series/conftest.py b/pandas/tests/series/conftest.py index dc778b96edb99..18d3c87a01f87 100644 --- a/pandas/tests/series/conftest.py +++ b/pandas/tests/series/conftest.py @@ -1,6 +1,5 @@ import pytest -import pandas as pd import pandas.util.testing as tm @@ -32,11 +31,3 @@ def object_series(): s = tm.makeObjectSeries() s.name = "objects" return s - - -@pytest.fixture -def empty_series(): - """ - Fixture for Series that is empty - """ - return pd.Series([], index=[]) diff --git a/pandas/tests/series/test_repr.py b/pandas/tests/series/test_repr.py index 5b0323b02f3cb..9f881f5a5aa29 100644 --- a/pandas/tests/series/test_repr.py +++ b/pandas/tests/series/test_repr.py @@ -65,7 +65,7 @@ def test_name_printing(self): s = Series(index=date_range("20010101", "20020101"), name="test") assert "Name: test" in repr(s) - def test_repr(self, datetime_series, string_series, object_series, empty_series): + def test_repr(self, datetime_series, string_series, object_series): str(datetime_series) str(string_series) str(string_series.astype(int)) @@ -75,7 +75,7 @@ def test_repr(self, datetime_series, string_series, object_series, empty_series) str(Series(tm.randn(1000), index=np.arange(1000, 0, step=-1))) # empty - str(empty_series) + str(Series()) # with NaNs string_series[5:7] = np.NaN