From 5d9a1cfb035379e8b8bd3d46e06a48d16150d823 Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Sat, 10 Nov 2018 07:14:15 -0600 Subject: [PATCH 1/2] TST: Unskip some Categorical Tests closes https://github.com/pandas-dev/pandas/issues/20747 --- pandas/tests/extension/test_categorical.py | 97 +++++++++------------- 1 file changed, 41 insertions(+), 56 deletions(-) diff --git a/pandas/tests/extension/test_categorical.py b/pandas/tests/extension/test_categorical.py index b1d08a5620bf3..814323357f72a 100644 --- a/pandas/tests/extension/test_categorical.py +++ b/pandas/tests/extension/test_categorical.py @@ -16,13 +16,13 @@ import string import numpy as np -import pytest import pandas as pd from pandas import Categorical from pandas.api.types import CategoricalDtype from pandas.tests.extension import base import pandas.util.testing as tm +import pytest def make_data(): @@ -73,10 +73,10 @@ class TestDtype(base.BaseDtypeTests): class TestInterface(base.BaseInterfaceTests): - @pytest.mark.skip(reason="Memory usage doesn't match") - def test_memory_usage(self): + @pytest.mark.skip(reason="Memory usage doesn't match", strict=True) + def test_memory_usage(self, data): # Is this deliberate? - pass + super(TestInterface, self).test_memory_usage(data) class TestConstructors(base.BaseConstructorsTests): @@ -84,69 +84,56 @@ class TestConstructors(base.BaseConstructorsTests): class TestReshaping(base.BaseReshapingTests): - @pytest.mark.skip(reason="Unobserved categories preseved in concat.") - def test_concat_columns(self, data, na_value): - pass - - @pytest.mark.skip(reason="Unobserved categories preseved in concat.") - def test_align(self, data, na_value): - pass - - @pytest.mark.skip(reason="Unobserved categories preseved in concat.") - def test_align_frame(self, data, na_value): - pass - - @pytest.mark.skip(reason="Unobserved categories preseved in concat.") - def test_merge(self, data, na_value): - pass + pass class TestGetitem(base.BaseGetitemTests): - skip_take = pytest.mark.skip(reason="GH-20664.") + skip_take = pytest.mark.skip(reason="GH-20664.", strict=True) - @pytest.mark.skip(reason="Backwards compatibility") - def test_getitem_scalar(self): + @pytest.mark.skip(reason="Backwards compatibility", strict=True) + def test_getitem_scalar(self, data): # CategoricalDtype.type isn't "correct" since it should # be a parent of the elements (object). But don't want # to break things by changing. - pass + super(TestGetitem, self).test_getitem_scalar(data) @skip_take - def test_take(self): + def test_take(self, data, na_value, na_cmp): # TODO remove this once Categorical.take is fixed - pass + super(TestGetitem, self).test_take(data, na_value, na_cmp) @skip_take - def test_take_negative(self): - pass + def test_take_negative(self, data): + super().test_take_negative(data) @skip_take - def test_take_pandas_style_negative_raises(self): - pass + def test_take_pandas_style_negative_raises(self, data, na_value): + super().test_take_pandas_style_negative_raises(data, na_value) @skip_take - def test_take_non_na_fill_value(self): - pass + def test_take_non_na_fill_value(self, data_missing): + super().test_take_non_na_fill_value(data_missing) @skip_take - def test_take_out_of_bounds_raises(self): - pass + def test_take_out_of_bounds_raises(self, data, allow_fill): + return super().test_take_out_of_bounds_raises(data, allow_fill) - @pytest.mark.skip(reason="GH-20747. Unobserved categories.") - def test_take_series(self): - pass + @pytest.mark.skip(reason="GH-20747. Unobserved categories.", strict=True) + def test_take_series(self, data): + super().test_take_series(data) @skip_take - def test_reindex_non_na_fill_value(self): - pass + def test_reindex_non_na_fill_value(self, data_missing): + super().test_reindex_non_na_fill_value(data_missing) - @pytest.mark.skip(reason="Categorical.take buggy") - def test_take_empty(self): - pass + @pytest.mark.skip(reason="Categorical.take buggy", strict=True) + def test_take_empty(self, data, na_value, na_cmp): + super().test_take_empty(data, na_value, na_cmp) - @pytest.mark.skip(reason="test not written correctly for categorical") - def test_reindex(self): - pass + @pytest.mark.skip(reason="test not written correctly for categorical", + strict=True) + def test_reindex(self, data, na_value): + super().test_reindex(data, na_value) class TestSetitem(base.BaseSetitemTests): @@ -155,13 +142,13 @@ class TestSetitem(base.BaseSetitemTests): class TestMissing(base.BaseMissingTests): - @pytest.mark.skip(reason="Not implemented") - def test_fillna_limit_pad(self): - pass + @pytest.mark.skip(reason="Not implemented", strict=True) + def test_fillna_limit_pad(self, data_missing): + super().test_fillna_limit_pad(data_missing) - @pytest.mark.skip(reason="Not implemented") - def test_fillna_limit_backfill(self): - pass + @pytest.mark.skip(reason="Not implemented", strict=True) + def test_fillna_limit_backfill(self, data_missing): + super().test_fillna_limit_backfill(data_missing) class TestReduce(base.BaseNoReduceTests): @@ -169,11 +156,9 @@ class TestReduce(base.BaseNoReduceTests): class TestMethods(base.BaseMethodsTests): - pass - - @pytest.mark.skip(reason="Unobserved categories included") + @pytest.mark.skip(reason="Unobserved categories included", strict=True) def test_value_counts(self, all_data, dropna): - pass + return super().test_value_counts(all_data, dropna) def test_combine_add(self, data_repeated): # GH 20825 @@ -191,9 +176,9 @@ def test_combine_add(self, data_repeated): expected = pd.Series([a + val for a in list(orig_data1)]) self.assert_series_equal(result, expected) - @pytest.mark.skip(reason="Not Applicable") + @pytest.mark.skip(reason="Not Applicable", strict=True) def test_fillna_length_mismatch(self, data_missing): - pass + super().test_fillna_length_mismatch(data_missing) class TestCasting(base.BaseCastingTests): From afe6c83cdc0e9df6e83c8db7376a2c71b7857856 Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Sat, 10 Nov 2018 14:25:03 -0600 Subject: [PATCH 2/2] isort --- pandas/tests/extension/test_categorical.py | 2 +- setup.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/tests/extension/test_categorical.py b/pandas/tests/extension/test_categorical.py index 814323357f72a..8810c535c655f 100644 --- a/pandas/tests/extension/test_categorical.py +++ b/pandas/tests/extension/test_categorical.py @@ -16,13 +16,13 @@ import string import numpy as np +import pytest import pandas as pd from pandas import Categorical from pandas.api.types import CategoricalDtype from pandas.tests.extension import base import pandas.util.testing as tm -import pytest def make_data(): diff --git a/setup.cfg b/setup.cfg index 4726a0ddb2fb2..2e07182196d5b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -90,7 +90,7 @@ known_post_core=pandas.tseries,pandas.io,pandas.plotting sections=FUTURE,STDLIB,THIRDPARTY,PRE_CORE,DTYPES,FIRSTPARTY,POST_CORE,LOCALFOLDER known_first_party=pandas -known_third_party=Cython,numpy,python-dateutil,pytz,pyarrow +known_third_party=Cython,numpy,python-dateutil,pytz,pyarrow,pytest multi_line_output=4 force_grid_wrap=0 combine_as_imports=True