Skip to content

Commit f36c2d7

Browse files
jbrockmendelquintusdias
authored andcommitted
TST: troubleshoot inconsistent xfails (pandas-dev#27715)
1 parent 560ae29 commit f36c2d7

File tree

15 files changed

+31
-44
lines changed

15 files changed

+31
-44
lines changed

pandas/compat/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import struct
1212
import sys
1313

14+
PY35 = sys.version_info[:2] == (3, 5)
1415
PY36 = sys.version_info >= (3, 6)
1516
PY37 = sys.version_info >= (3, 7)
1617
PYPY = platform.python_implementation() == "PyPy"

pandas/tests/arithmetic/test_datetime64.py

+1
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,7 @@ def test_comparison_tzawareness_compat_scalars(self, op, box_with_array):
666666
# Raising in __eq__ will fallback to NumPy, which warns, fails,
667667
# then re-raises the original exception. So we just need to ignore.
668668
@pytest.mark.filterwarnings("ignore:elementwise comp:DeprecationWarning")
669+
@pytest.mark.filterwarnings("ignore:Converting timezone-aware:FutureWarning")
669670
def test_scalar_comparison_tzawareness(
670671
self, op, other, tz_aware_fixture, box_with_array
671672
):

pandas/tests/computation/test_eval.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1789,9 +1789,10 @@ def test_result_types(self):
17891789
self.check_result_type(np.float32, np.float32)
17901790
self.check_result_type(np.float64, np.float64)
17911791

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

17961797
# Did not test complex64 because DataFrame is converting it to
17971798
# complex128. Due to https://github.com/pandas-dev/pandas/issues/10952

pandas/tests/extension/test_datetime.py

-16
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,6 @@ def test_divmod_series_array(self):
142142
# skipping because it is not implemented
143143
pass
144144

145-
@pytest.mark.xfail(reason="different implementation", strict=False)
146-
def test_direct_arith_with_series_returns_not_implemented(self, data):
147-
# Right now, we have trouble with this. Returning NotImplemented
148-
# fails other tests like
149-
# tests/arithmetic/test_datetime64::TestTimestampSeriesArithmetic::
150-
# test_dt64_seris_add_intlike
151-
return super(
152-
TestArithmeticOps, self
153-
).test_direct_arith_with_series_returns_not_implemented(data)
154-
155145

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

166-
@pytest.mark.xfail(reason="different implementation", strict=False)
167-
def test_direct_arith_with_series_returns_not_implemented(self, data):
168-
return super(
169-
TestComparisonOps, self
170-
).test_direct_arith_with_series_returns_not_implemented(data)
171-
172156

173157
class TestMissing(BaseDatetimeTests, base.BaseMissingTests):
174158
pass

pandas/tests/frame/test_analytics.py

+11-4
Original file line numberDiff line numberDiff line change
@@ -1819,10 +1819,17 @@ def test_any_all_bool_only(self):
18191819
(np.any, {"A": pd.Series([0, 1], dtype="category")}, True),
18201820
(np.all, {"A": pd.Series([1, 2], dtype="category")}, True),
18211821
(np.any, {"A": pd.Series([1, 2], dtype="category")}, True),
1822-
# # Mix
1823-
# GH 21484
1824-
# (np.all, {'A': pd.Series([10, 20], dtype='M8[ns]'),
1825-
# 'B': pd.Series([10, 20], dtype='m8[ns]')}, True),
1822+
# Mix GH#21484
1823+
pytest.param(
1824+
np.all,
1825+
{
1826+
"A": pd.Series([10, 20], dtype="M8[ns]"),
1827+
"B": pd.Series([10, 20], dtype="m8[ns]"),
1828+
},
1829+
True,
1830+
# In 1.13.3 and 1.14 np.all(df) returns a Timedelta here
1831+
marks=[td.skip_if_np_lt("1.15")],
1832+
),
18261833
],
18271834
)
18281835
def test_any_all_np_func(self, func, data, expected):

pandas/tests/groupby/test_categorical.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import numpy as np
55
import pytest
66

7-
from pandas.compat import PY37
8-
97
import pandas as pd
108
from pandas import (
119
Categorical,
@@ -209,7 +207,7 @@ def test_level_get_group(observed):
209207
assert_frame_equal(result, expected)
210208

211209

212-
@pytest.mark.xfail(PY37, reason="flaky on 3.7, xref gh-21636", strict=False)
210+
# GH#21636 previously flaky on py37
213211
@pytest.mark.parametrize("ordered", [True, False])
214212
def test_apply(ordered):
215213
# GH 10138

pandas/tests/indexes/datetimes/test_construction.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -759,14 +759,16 @@ def test_constructor_with_int_tz(self, klass, box, tz, dtype):
759759
assert result == expected
760760

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

772774
def test_construction_from_replaced_timestamps_with_dst(self):

pandas/tests/indexes/datetimes/test_tools.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -741,10 +741,7 @@ def test_to_datetime_tz_psycopg2(self, cache):
741741
)
742742
tm.assert_index_equal(result, expected)
743743

744-
@pytest.mark.parametrize(
745-
"cache",
746-
[pytest.param(True, marks=pytest.mark.skipif(True, reason="GH 18111")), False],
747-
)
744+
@pytest.mark.parametrize("cache", [True, False])
748745
def test_datetime_bool(self, cache):
749746
# GH13176
750747
with pytest.raises(TypeError):

pandas/tests/io/formats/test_to_csv.py

-1
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,6 @@ def test_to_csv_string_array_ascii(self):
340340
with open(path, "r") as f:
341341
assert f.read() == expected_ascii
342342

343-
@pytest.mark.xfail(strict=False)
344343
def test_to_csv_string_array_utf8(self):
345344
# GH 10813
346345
str_array = [{"names": ["foo", "bar"]}, {"names": ["baz", "qux"]}]

pandas/tests/io/test_parquet.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
except ImportError:
3434
_HAVE_FASTPARQUET = False
3535

36+
pytestmark = pytest.mark.filterwarnings(
37+
"ignore:RangeIndex.* is deprecated:DeprecationWarning"
38+
)
39+
3640

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

409413
check_round_trip(df, pa)
410414

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

pandas/tests/plotting/test_datetimelike.py

-1
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,6 @@ def test_time(self):
10981098
assert xp == rs
10991099

11001100
@pytest.mark.slow
1101-
@pytest.mark.xfail(strict=False, reason="Unreliable test")
11021101
def test_time_change_xlim(self):
11031102
t = datetime(1, 1, 1, 3, 30, 0)
11041103
deltas = np.random.randint(1, 20, 3).cumsum()

pandas/tests/scalar/period/test_period.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from pandas._libs.tslibs.parsing import DateParseError
1111
from pandas._libs.tslibs.period import IncompatibleFrequency
1212
from pandas._libs.tslibs.timezones import dateutil_gettz, maybe_get_tz
13+
from pandas.compat import PY35
1314
from pandas.compat.numpy import np_datetime64_compat
1415

1516
import pandas as pd
@@ -1579,8 +1580,9 @@ def test_period_immutable():
15791580
per.freq = 2 * freq
15801581

15811582

1582-
# TODO: This doesn't fail on all systems; track down which
1583-
@pytest.mark.xfail(reason="Parses as Jan 1, 0007 on some systems", strict=False)
1583+
@pytest.mark.xfail(
1584+
PY35, reason="Parsing as Period('0007-01-01', 'D') for reasons unknown", strict=True
1585+
)
15841586
def test_small_year_parsing():
15851587
per1 = Period("0001-01-07", "D")
15861588
assert per1.year == 1

pandas/tests/series/test_analytics.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1489,7 +1489,7 @@ def test_value_counts_with_nan(self):
14891489
"unicode_",
14901490
"timedelta64[h]",
14911491
pytest.param(
1492-
"datetime64[D]", marks=pytest.mark.xfail(reason="GH#7996", strict=False)
1492+
"datetime64[D]", marks=pytest.mark.xfail(reason="GH#7996", strict=True)
14931493
),
14941494
],
14951495
)

pandas/tests/sparse/test_combine_concat.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ def test_concat_sparse_dense_rows(self, fill_value, sparse_idx, dense_idx):
440440
"fill_value,sparse_idx,dense_idx",
441441
itertools.product([None, 0, 1, np.nan], [0, 1], [1, 0]),
442442
)
443-
@pytest.mark.xfail(reason="The iloc fails and I can't make expected", strict=False)
443+
@pytest.mark.xfail(reason="The iloc fails and I can't make expected", strict=True)
444444
def test_concat_sparse_dense_cols(self, fill_value, sparse_idx, dense_idx):
445445
# See GH16874, GH18914 and #18686 for why this should be a DataFrame
446446
from pandas.core.dtypes.common import is_sparse

pandas/tests/sparse/test_pivot.py

-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import pytest
33

44
import pandas as pd
5-
from pandas import _np_version_under1p17
65
import pandas.util.testing as tm
76

87

@@ -49,11 +48,6 @@ def test_pivot_table_with_nans(self):
4948
)
5049
tm.assert_frame_equal(res_sparse, res_dense)
5150

52-
@pytest.mark.xfail(
53-
not _np_version_under1p17,
54-
reason="failing occasionally on numpy > 1.17",
55-
strict=False,
56-
)
5751
def test_pivot_table_multi(self):
5852
res_sparse = pd.pivot_table(
5953
self.sparse, index="A", columns="B", values=["D", "E"]

0 commit comments

Comments
 (0)