Skip to content

TST: Fix warnings & skip -> xfail #46370

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 5 commits into from
Mar 16, 2022
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
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
/opt/python/cp38-cp38/bin/python -m venv ~/virtualenvs/pandas-dev && \
. ~/virtualenvs/pandas-dev/bin/activate && \
python -m pip install --no-deps -U pip wheel 'setuptools<60.0.0' && \
pip install cython numpy python-dateutil pytz pytest pytest-xdist hypothesis && \
pip install cython numpy python-dateutil pytz pytest pytest-xdist pytest-asyncio hypothesis && \
python setup.py build_ext -q -j2 && \
python -m pip install --no-build-isolation -e . && \
pytest -m 'not slow and not network and not clipboard and not single_cpu' pandas --junitxml=test-data.xml"
Expand Down
1 change: 1 addition & 0 deletions ci/deps/actions-310-numpydev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dependencies:
- pytest-cov
- pytest-xdist>=1.31
- hypothesis>=5.5.3
- pytest-asyncio

# pandas dependencies
- python-dateutil
Expand Down
1 change: 1 addition & 0 deletions ci/deps/circle-38-arm64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dependencies:
- pytest>=6.0
- pytest-xdist>=1.31
- hypothesis>=5.5.3
- pytest-asyncio

# pandas dependencies
- botocore>=1.11
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/arrays/string_/test_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ def test_memory_usage(dtype):
# GH 33963

if dtype.storage == "pyarrow":
pytest.skip("not applicable")
pytest.skip(f"not applicable for {dtype.storage}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a never-expected-to-change thing, i.e. shouldnt be an xfail?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume so since I think that would require a pyarrow API to get memory usage (didn't see one quickly skimming)


series = pd.Series(["a", "b", "c"], dtype=dtype)

Expand Down
17 changes: 11 additions & 6 deletions pandas/tests/extension/base/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,22 @@ def test_add_series_with_extension_array(self, data):
self.assert_series_equal(result, expected)

@pytest.mark.parametrize("box", [pd.Series, pd.DataFrame])
def test_direct_arith_with_ndframe_returns_not_implemented(self, data, box):
def test_direct_arith_with_ndframe_returns_not_implemented(
self, request, data, box
):
# EAs should return NotImplemented for ops with Series/DataFrame
# Pandas takes care of unboxing the series and calling the EA's op.
other = pd.Series(data)
if box is pd.DataFrame:
other = other.to_frame()
if hasattr(data, "__add__"):
result = data.__add__(other)
assert result is NotImplemented
else:
raise pytest.skip(f"{type(data).__name__} does not implement add")
if not hasattr(data, "__add__"):
request.node.add_marker(
pytest.mark.xfail(
reason=f"{type(data).__name__} does not implement add"
)
)
result = data.__add__(other)
assert result is NotImplemented


class BaseComparisonOpsTests(BaseOpsUtil):
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/extension/json/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,10 @@ def test_contains(self, data):


class TestConstructors(BaseJSON, base.BaseConstructorsTests):
@pytest.mark.skip(reason="not implemented constructor from dtype")
@pytest.mark.xfail(reason="not implemented constructor from dtype")
def test_from_dtype(self, data):
# construct from our dtype & string dtype
pass
super(self).test_from_dtype(data)

@pytest.mark.xfail(reason="RecursionError, GH-33900")
def test_series_constructor_no_data_with_index(self, dtype, na_value):
Expand Down
18 changes: 4 additions & 14 deletions pandas/tests/extension/test_categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def data():
"""Length-100 array for this type.

* data[0] and data[1] should both be non missing
* data[0] and data[1] should not gbe equal
* data[0] and data[1] should not be equal
"""
return Categorical(make_data())

Expand Down Expand Up @@ -86,7 +86,7 @@ class TestDtype(base.BaseDtypeTests):


class TestInterface(base.BaseInterfaceTests):
@pytest.mark.skip(reason="Memory usage doesn't match")
@pytest.mark.xfail(reason="Memory usage doesn't match")
def test_memory_usage(self, data):
# Is this deliberate?
super().test_memory_usage(data)
Expand Down Expand Up @@ -149,21 +149,15 @@ class TestIndex(base.BaseIndexTests):


class TestMissing(base.BaseMissingTests):
@pytest.mark.skip(reason="Not implemented")
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, data_missing):
super().test_fillna_limit_backfill(data_missing)
pass


class TestReduce(base.BaseNoReduceTests):
pass


class TestMethods(base.BaseMethodsTests):
@pytest.mark.skip(reason="Unobserved categories included")
@pytest.mark.xfail(reason="Unobserved categories included")
def test_value_counts(self, all_data, dropna):
return super().test_value_counts(all_data, dropna)

Expand All @@ -184,10 +178,6 @@ 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")
def test_fillna_length_mismatch(self, data_missing):
super().test_fillna_length_mismatch(data_missing)


class TestCasting(base.BaseCastingTests):
@pytest.mark.parametrize("cls", [Categorical, CategoricalIndex])
Expand Down
4 changes: 1 addition & 3 deletions pandas/tests/extension/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,7 @@ class TestMissing(BaseDatetimeTests, base.BaseMissingTests):


class TestReshaping(BaseDatetimeTests, base.BaseReshapingTests):
@pytest.mark.skip(reason="We have DatetimeTZBlock")
def test_concat(self, data, in_frame):
pass
pass


class TestSetitem(BaseDatetimeTests, base.BaseSetitemTests):
Expand Down
24 changes: 13 additions & 11 deletions pandas/tests/extension/test_interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ def test_reduce_series_numeric(self, data, all_numeric_reductions, skipna):


class TestMethods(BaseInterval, base.BaseMethodsTests):
@pytest.mark.skip(reason="addition is not defined for intervals")
@pytest.mark.xfail(reason="addition is not defined for intervals")
def test_combine_add(self, data_repeated):
pass
super().test_combine_add(data_repeated)

@pytest.mark.xfail(
reason="Raises with incorrect message bc it disallows *all* listlikes "
Expand All @@ -134,29 +134,31 @@ def test_fillna_length_mismatch(self, data_missing):


class TestMissing(BaseInterval, base.BaseMissingTests):
# Index.fillna only accepts scalar `value`, so we have to skip all
# Index.fillna only accepts scalar `value`, so we have to xfail all
# non-scalar fill tests.
unsupported_fill = pytest.mark.skip("Unsupported fillna option.")
unsupported_fill = pytest.mark.xfail(
reason="Unsupported fillna option for Interval."
)

@unsupported_fill
def test_fillna_limit_pad(self):
pass
super().test_fillna_limit_pad()

@unsupported_fill
def test_fillna_series_method(self):
pass
super().test_fillna_series_method()

@unsupported_fill
def test_fillna_limit_backfill(self):
pass
super().test_fillna_limit_backfill()

@unsupported_fill
def test_fillna_no_op_returns_copy(self):
pass
super().test_fillna_no_op_returns_copy()

@unsupported_fill
def test_fillna_series(self):
pass
super().test_fillna_series()

def test_fillna_non_scalar_raises(self, data_missing):
msg = "can only insert Interval objects and NA into an IntervalArray"
Expand All @@ -173,9 +175,9 @@ class TestSetitem(BaseInterval, base.BaseSetitemTests):


class TestPrinting(BaseInterval, base.BasePrintingTests):
@pytest.mark.skip(reason="custom repr")
@pytest.mark.xfail(reason="Interval has custom repr")
def test_array_repr(self, data, size):
pass
super().test_array_repr()


class TestParsing(BaseInterval, base.BaseParsingTests):
Expand Down
18 changes: 9 additions & 9 deletions pandas/tests/extension/test_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,15 @@ def test_series_constructor_scalar_with_index(self, data, dtype):


class TestDtype(BaseNumPyTests, base.BaseDtypeTests):
@pytest.mark.skip(reason="Incorrect expected.")
# we unsurprisingly clash with a NumPy name.
def test_check_dtype(self, data):
pass
def test_check_dtype(self, data, request):
if data.dtype.numpy_dtype == "object":
request.node.add_marker(
pytest.mark.xfail(
reason=f"PandasArray expectedly clashes with a "
f"NumPy name: {data.dtype.numpy_dtype}"
)
)
super().test_check_dtype(data)


class TestGetitem(BaseNumPyTests, base.BaseGetitemTests):
Expand Down Expand Up @@ -345,11 +350,6 @@ def test_fillna_frame(self, data_missing):


class TestReshaping(BaseNumPyTests, base.BaseReshapingTests):
@pytest.mark.skip(reason="Incorrect expected.")
def test_merge(self, data, na_value):
# Fails creating expected (key column becomes a PandasDtype because)
super().test_merge(data, na_value)

@pytest.mark.parametrize(
"in_frame",
[
Expand Down
10 changes: 3 additions & 7 deletions pandas/tests/extension/test_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

def split_array(arr):
if arr.dtype.storage != "pyarrow":
pytest.skip("chunked array n/a")
pytest.skip("only applicable for pyarrow chunked array n/a")

def _split_array(arr):
import pyarrow as pa
Expand Down Expand Up @@ -156,13 +156,9 @@ def test_reduce_series_numeric(self, data, all_numeric_reductions, skipna):


class TestMethods(base.BaseMethodsTests):
@pytest.mark.skip(reason="returns nullable")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yah really ought to pull the trigger on #44692 and just get internal consistency here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added that issue ref to this xfail

def test_value_counts(self, all_data, dropna):
return super().test_value_counts(all_data, dropna)

@pytest.mark.skip(reason="returns nullable")
@pytest.mark.xfail(reason="returns nullable: GH 44692")
def test_value_counts_with_normalize(self, data):
pass
super().test_value_counts_with_normalize(data)


class TestCasting(base.BaseCastingTests):
Expand Down
7 changes: 3 additions & 4 deletions pandas/tests/plotting/frame/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,11 @@ def test_nullable_int_plot(self):
df = DataFrame(
{
"A": [1, 2, 3, 4, 5],
"B": [1.0, 2.0, 3.0, 4.0, 5.0],
"C": [7, 5, np.nan, 3, 2],
"B": [1, 2, 3, 4, 5],
"C": np.array([7, 5, np.nan, 3, 2], dtype=object),
"D": pd.to_datetime(dates, format="%Y").view("i8"),
"E": pd.to_datetime(dates, format="%Y", utc=True).view("i8"),
},
dtype=np.int64,
}
)

_check_plot_works(df.plot, x="A", y="B")
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/plotting/test_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def test_conversion(self):

rs = self.pc.convert(
np.array(
["2012-01-01 00:00:00+0000", "2012-01-02 00:00:00+0000"],
["2012-01-01 00:00:00", "2012-01-02 00:00:00"],
dtype="datetime64[ns]",
),
None,
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ markers = [
"arm_slow: mark a test as slow for arm64 architecture",
"arraymanager: mark a test to run with ArrayManager enabled",
]
asyncio_mode = "strict"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where do we use asyncio?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have some tab completion tests that use this

(pandas-dev) ...  % grep --include="*.py" "async def" pandas/tests -r
pandas/tests/resample/test_resampler_grouper.py:async def test_tab_complete_ipython6_warning(ip):
pandas/tests/frame/test_api.py:    async def test_tab_complete_warning(self, ip, frame_or_series):
pandas/tests/arrays/categorical/test_warnings.py:    async def test_tab_complete_warning(self, ip):
pandas/tests/indexes/test_base.py:    async def test_tab_complete_warning(self, ip):


[tool.mypy]
# Import discovery
Expand Down