Skip to content

Backport PR #27715 on branch 0.25.x (TST: troubleshoot inconsistent xfails) #27752

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
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
1 change: 1 addition & 0 deletions pandas/compat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import struct
import sys

PY35 = sys.version_info[:2] == (3, 5)
PY36 = sys.version_info >= (3, 6)
PY37 = sys.version_info >= (3, 7)
PYPY = platform.python_implementation() == "PyPy"
Expand Down
1 change: 1 addition & 0 deletions pandas/tests/arithmetic/test_datetime64.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,7 @@ def test_comparison_tzawareness_compat_scalars(self, op, box_with_array):
# Raising in __eq__ will fallback to NumPy, which warns, fails,
# then re-raises the original exception. So we just need to ignore.
@pytest.mark.filterwarnings("ignore:elementwise comp:DeprecationWarning")
@pytest.mark.filterwarnings("ignore:Converting timezone-aware:FutureWarning")
def test_scalar_comparison_tzawareness(
self, op, other, tz_aware_fixture, box_with_array
):
Expand Down
5 changes: 3 additions & 2 deletions pandas/tests/computation/test_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -1789,9 +1789,10 @@ def test_result_types(self):
self.check_result_type(np.float32, np.float32)
self.check_result_type(np.float64, np.float64)

def test_result_types2(self):
@td.skip_if_windows
def test_result_complex128(self):
# xref https://github.com/pandas-dev/pandas/issues/12293
pytest.skip("unreliable tests on complex128")
# this fails on Windows, apparently a floating point precision issue

# Did not test complex64 because DataFrame is converting it to
# complex128. Due to https://github.com/pandas-dev/pandas/issues/10952
Expand Down
16 changes: 0 additions & 16 deletions pandas/tests/extension/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,6 @@ def test_divmod_series_array(self):
# skipping because it is not implemented
pass

@pytest.mark.xfail(reason="different implementation", strict=False)
def test_direct_arith_with_series_returns_not_implemented(self, data):
# Right now, we have trouble with this. Returning NotImplemented
# fails other tests like
# tests/arithmetic/test_datetime64::TestTimestampSeriesArithmetic::
# test_dt64_seris_add_intlike
return super(
TestArithmeticOps, self
).test_direct_arith_with_series_returns_not_implemented(data)


class TestCasting(BaseDatetimeTests, base.BaseCastingTests):
pass
Expand All @@ -163,12 +153,6 @@ def _compare_other(self, s, data, op_name, other):
# with (some) integers, depending on the value.
pass

@pytest.mark.xfail(reason="different implementation", strict=False)
def test_direct_arith_with_series_returns_not_implemented(self, data):
return super(
TestComparisonOps, self
).test_direct_arith_with_series_returns_not_implemented(data)


class TestMissing(BaseDatetimeTests, base.BaseMissingTests):
pass
Expand Down
15 changes: 11 additions & 4 deletions pandas/tests/frame/test_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -1819,10 +1819,17 @@ def test_any_all_bool_only(self):
(np.any, {"A": pd.Series([0, 1], dtype="category")}, True),
(np.all, {"A": pd.Series([1, 2], dtype="category")}, True),
(np.any, {"A": pd.Series([1, 2], dtype="category")}, True),
# # Mix
# GH 21484
# (np.all, {'A': pd.Series([10, 20], dtype='M8[ns]'),
# 'B': pd.Series([10, 20], dtype='m8[ns]')}, True),
# Mix GH#21484
pytest.param(
np.all,
{
"A": pd.Series([10, 20], dtype="M8[ns]"),
"B": pd.Series([10, 20], dtype="m8[ns]"),
},
True,
# In 1.13.3 and 1.14 np.all(df) returns a Timedelta here
marks=[td.skip_if_np_lt("1.15")],
),
],
)
def test_any_all_np_func(self, func, data, expected):
Expand Down
4 changes: 1 addition & 3 deletions pandas/tests/groupby/test_categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import numpy as np
import pytest

from pandas.compat import PY37

import pandas as pd
from pandas import (
Categorical,
Expand Down Expand Up @@ -209,7 +207,7 @@ def test_level_get_group(observed):
assert_frame_equal(result, expected)


@pytest.mark.xfail(PY37, reason="flaky on 3.7, xref gh-21636", strict=False)
# GH#21636 previously flaky on py37
@pytest.mark.parametrize("ordered", [True, False])
def test_apply(ordered):
# GH 10138
Expand Down
4 changes: 3 additions & 1 deletion pandas/tests/indexes/datetimes/test_construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,14 +759,16 @@ def test_constructor_with_int_tz(self, klass, box, tz, dtype):
assert result == expected

# This is the desired future behavior
# Note: this xfail is not strict because the test passes with
# None or any of the UTC variants for tz_naive_fixture
@pytest.mark.xfail(reason="Future behavior", strict=False)
@pytest.mark.filterwarnings("ignore:\\n Passing:FutureWarning")
def test_construction_int_rountrip(self, tz_naive_fixture):
# GH 12619
# TODO(GH-24559): Remove xfail
tz = tz_naive_fixture
result = 1293858000000000000
expected = DatetimeIndex([1293858000000000000], tz=tz).asi8[0]
expected = DatetimeIndex([result], tz=tz).asi8[0]
assert result == expected

def test_construction_from_replaced_timestamps_with_dst(self):
Expand Down
5 changes: 1 addition & 4 deletions pandas/tests/indexes/datetimes/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,10 +741,7 @@ def test_to_datetime_tz_psycopg2(self, cache):
)
tm.assert_index_equal(result, expected)

@pytest.mark.parametrize(
"cache",
[pytest.param(True, marks=pytest.mark.skipif(True, reason="GH 18111")), False],
)
@pytest.mark.parametrize("cache", [True, False])
def test_datetime_bool(self, cache):
# GH13176
with pytest.raises(TypeError):
Expand Down
1 change: 0 additions & 1 deletion pandas/tests/io/formats/test_to_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,6 @@ def test_to_csv_string_array_ascii(self):
with open(path, "r") as f:
assert f.read() == expected_ascii

@pytest.mark.xfail(strict=False)
def test_to_csv_string_array_utf8(self):
# GH 10813
str_array = [{"names": ["foo", "bar"]}, {"names": ["baz", "qux"]}]
Expand Down
6 changes: 4 additions & 2 deletions pandas/tests/io/test_parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
except ImportError:
_HAVE_FASTPARQUET = False

pytestmark = pytest.mark.filterwarnings(
"ignore:RangeIndex.* is deprecated:DeprecationWarning"
)


# setup engines & skips
@pytest.fixture(
Expand Down Expand Up @@ -408,8 +412,6 @@ def test_basic(self, pa, df_full):

check_round_trip(df, pa)

# TODO: This doesn't fail on all systems; track down which
@pytest.mark.xfail(reason="pyarrow fails on this (ARROW-1883)", strict=False)
def test_basic_subset_columns(self, pa, df_full):
# GH18628

Expand Down
1 change: 0 additions & 1 deletion pandas/tests/plotting/test_datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,6 @@ def test_time(self):
assert xp == rs

@pytest.mark.slow
@pytest.mark.xfail(strict=False, reason="Unreliable test")
def test_time_change_xlim(self):
t = datetime(1, 1, 1, 3, 30, 0)
deltas = np.random.randint(1, 20, 3).cumsum()
Expand Down
6 changes: 4 additions & 2 deletions pandas/tests/scalar/period/test_period.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from pandas._libs.tslibs.parsing import DateParseError
from pandas._libs.tslibs.period import IncompatibleFrequency
from pandas._libs.tslibs.timezones import dateutil_gettz, maybe_get_tz
from pandas.compat import PY35
from pandas.compat.numpy import np_datetime64_compat

import pandas as pd
Expand Down Expand Up @@ -1579,8 +1580,9 @@ def test_period_immutable():
per.freq = 2 * freq


# TODO: This doesn't fail on all systems; track down which
@pytest.mark.xfail(reason="Parses as Jan 1, 0007 on some systems", strict=False)
@pytest.mark.xfail(
PY35, reason="Parsing as Period('0007-01-01', 'D') for reasons unknown", strict=True
)
def test_small_year_parsing():
per1 = Period("0001-01-07", "D")
assert per1.year == 1
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/series/test_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -1489,7 +1489,7 @@ def test_value_counts_with_nan(self):
"unicode_",
"timedelta64[h]",
pytest.param(
"datetime64[D]", marks=pytest.mark.xfail(reason="GH#7996", strict=False)
"datetime64[D]", marks=pytest.mark.xfail(reason="GH#7996", strict=True)
),
],
)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/sparse/test_combine_concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ def test_concat_sparse_dense_rows(self, fill_value, sparse_idx, dense_idx):
"fill_value,sparse_idx,dense_idx",
itertools.product([None, 0, 1, np.nan], [0, 1], [1, 0]),
)
@pytest.mark.xfail(reason="The iloc fails and I can't make expected", strict=False)
@pytest.mark.xfail(reason="The iloc fails and I can't make expected", strict=True)
def test_concat_sparse_dense_cols(self, fill_value, sparse_idx, dense_idx):
# See GH16874, GH18914 and #18686 for why this should be a DataFrame
from pandas.core.dtypes.common import is_sparse
Expand Down
6 changes: 0 additions & 6 deletions pandas/tests/sparse/test_pivot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import pytest

import pandas as pd
from pandas import _np_version_under1p17
import pandas.util.testing as tm


Expand Down Expand Up @@ -49,11 +48,6 @@ def test_pivot_table_with_nans(self):
)
tm.assert_frame_equal(res_sparse, res_dense)

@pytest.mark.xfail(
not _np_version_under1p17,
reason="failing occasionally on numpy > 1.17",
strict=False,
)
def test_pivot_table_multi(self):
res_sparse = pd.pivot_table(
self.sparse, index="A", columns="B", values=["D", "E"]
Expand Down