Skip to content

[TST] make xfails strict #22139

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 2 commits into from
Aug 1, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion pandas/tests/arrays/categorical/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,8 @@ def test_construction_with_ordered(self):
cat = Categorical([0, 1, 2], ordered=True)
assert cat.ordered

@pytest.mark.xfail(reason="Imaginary values not supported in Categorical")
@pytest.mark.xfail(reason="Imaginary values not supported in Categorical",
strict=True)
def test_constructor_imaginary(self):
values = [1, 2, 3 + 1j]
c1 = Categorical(values)
Expand Down
3 changes: 2 additions & 1 deletion pandas/tests/extension/base/setitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ def test_setitem_frame_invalid_length(self, data):
with tm.assert_raises_regex(ValueError, xpr):
df['B'] = data[:5]

@pytest.mark.xfail(reason="GH-20441: setitem on extension types.")
@pytest.mark.xfail(reason="GH#20441: setitem on extension types.",
strict=True)
def test_setitem_tuple_index(self, data):
s = pd.Series(data[:2], index=[(0, 0), (0, 1)])
expected = pd.Series(data.take([1, 1]), index=s.index)
Expand Down
10 changes: 7 additions & 3 deletions pandas/tests/extension/integer/test_integer.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,13 +599,17 @@ def test_construct_cast_invalid(self, dtype):

class TestGroupby(BaseInteger, base.BaseGroupbyTests):

@pytest.mark.xfail(reason="groupby not working")
@pytest.mark.xfail(reason="groupby not working", strict=True)
def test_groupby_extension_no_sort(self, data_for_grouping):
super(TestGroupby, self).test_groupby_extension_no_sort(
data_for_grouping)

@pytest.mark.xfail(reason="groupby not working")
@pytest.mark.parametrize('as_index', [True, False])
@pytest.mark.parametrize('as_index', [
pytest.param(True,
marks=pytest.mark.xfail(reason="groupby not working",
strict=True)),
False
])
def test_groupby_extension_agg(self, as_index, data_for_grouping):
super(TestGroupby, self).test_groupby_extension_agg(
as_index, data_for_grouping)
Expand Down
5 changes: 4 additions & 1 deletion pandas/tests/extension/json/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ def test_custom_asserts(self):

class TestConstructors(BaseJSON, base.BaseConstructorsTests):

# TODO: Should this be pytest.mark.skip?
Copy link
Contributor

Choose a reason for hiding this comment

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

yeah u can change to skip (and similar ones)

@pytest.mark.xfail(reason="not implemented constructor from dtype")
def test_from_dtype(self, data):
# construct from our dtype & string dtype
Expand All @@ -157,10 +158,12 @@ class TestGetitem(BaseJSON, base.BaseGetitemTests):


class TestMissing(BaseJSON, base.BaseMissingTests):
# TODO: Should this be pytest.mark.skip?
@pytest.mark.xfail(reason="Setting a dict as a scalar")
def test_fillna_series(self):
"""We treat dictionaries as a mapping in fillna, not a scalar."""

# TODO: Should this be pytest.mark.skip?
@pytest.mark.xfail(reason="Setting a dict as a scalar")
def test_fillna_frame(self):
"""We treat dictionaries as a mapping in fillna, not a scalar."""
Expand Down Expand Up @@ -212,7 +215,7 @@ def test_combine_add(self, data_repeated):


class TestCasting(BaseJSON, base.BaseCastingTests):

# TODO: Should this be pytest.mark.skip?
@pytest.mark.xfail(reason="failing on np.array(self, dtype=str)")
def test_astype_str(self):
"""This currently fails in NumPy on np.array(self, dtype=str) with
Expand Down
3 changes: 2 additions & 1 deletion pandas/tests/frame/test_arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ def test_df_div_zero_series_does_not_commute(self):

class TestFrameArithmetic(object):

@pytest.mark.xfail(reason='GH#7996 datetime64 units not converted to nano')
@pytest.mark.xfail(reason='GH#7996 datetime64 units not converted to nano',
strict=True)
def test_df_sub_datetime64_not_ns(self):
df = pd.DataFrame(pd.date_range('20130101', periods=3))
dt64 = np.datetime64('2013-01-01')
Expand Down
3 changes: 2 additions & 1 deletion pandas/tests/frame/test_duplicates.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ def test_duplicated_keep(keep, expected):
tm.assert_series_equal(result, expected)


@pytest.mark.xfail(reason="GH21720; nan/None falsely considered equal")
@pytest.mark.xfail(reason="GH#21720; nan/None falsely considered equal",
strict=True)
@pytest.mark.parametrize('keep, expected', [
('first', Series([False, False, True, False, True])),
('last', Series([True, True, False, False, False])),
Expand Down
12 changes: 11 additions & 1 deletion pandas/tests/groupby/aggregate/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,17 @@ def test_agg_structs_series(structure, expected):
tm.assert_series_equal(result, expected)


@pytest.mark.xfail(reason="GH-18869: agg func not called on empty groups.")
@pytest.mark.parametrize('observed', [
True,
pytest.param(False,
marks=pytest.mark.xfail(reason="GH#18869: agg func not "
"called on empty groups.",
strict=True)),
pytest.param(None,
marks=pytest.mark.xfail(reason="GH#18869: agg func not "
"called on empty groups.",
strict=True))
])
def test_agg_category_nansum(observed):
categories = ['a', 'b', 'c']
df = pd.DataFrame({"A": pd.Categorical(['a', 'a', 'b'],
Expand Down
7 changes: 4 additions & 3 deletions pandas/tests/groupby/test_apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ def test_apply_trivial():
tm.assert_frame_equal(result, expected)


@pytest.mark.xfail(reason=("GH 20066; function passed into apply "
"returns a DataFrame with the same index "
"as the one to create GroupBy object."))
@pytest.mark.xfail(reason="GH#20066; function passed into apply "
"returns a DataFrame with the same index "
"as the one to create GroupBy object.",
strict=True)
def test_apply_trivial_fail():
# GH 20066
# trivial apply fails if the constant dataframe has the same index
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/indexes/interval/test_astype.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def test_subtype_integer(self, subtype_start, subtype_end):
closed=index.closed)
tm.assert_index_equal(result, expected)

@pytest.mark.xfail(reason='GH 15832')
@pytest.mark.xfail(reason='GH#15832', strict=True)
def test_subtype_integer_errors(self):
# int64 -> uint64 fails with negative values
index = interval_range(-10, 10)
Expand Down Expand Up @@ -133,7 +133,7 @@ def test_subtype_integer(self, subtype):
with tm.assert_raises_regex(ValueError, msg):
index.insert(0, np.nan).astype(dtype)

@pytest.mark.xfail(reason='GH 15832')
@pytest.mark.xfail(reason='GH#15832', strict=True)
def test_subtype_integer_errors(self):
# float64 -> uint64 fails with negative values
index = interval_range(-10.0, 10.0)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/multi/test_missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def test_nulls(idx):
idx.isna()


@pytest.mark.xfail
@pytest.mark.xfail(strict=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

can u add a reason

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, will try to sort that out. Also waiting to see if anything fails on the CI that passed locally.

def test_hasnans_isnans(idx):
# GH 11343, added tests for hasnans / isnans
index = idx.copy()
Expand Down
3 changes: 2 additions & 1 deletion pandas/tests/indexes/period/test_arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,8 @@ def test_pi_add_sub_td64_array_non_tick_raises(self):
with pytest.raises(period.IncompatibleFrequency):
tdarr - rng

@pytest.mark.xfail(reason='op with TimedeltaIndex raises, with ndarray OK')
@pytest.mark.xfail(reason='op with TimedeltaIndex raises, with ndarray OK',
strict=True)
def test_pi_add_sub_td64_array_tick(self):
rng = pd.period_range('1/1/2000', freq='Q', periods=3)
dti = pd.date_range('2016-01-01', periods=3)
Expand Down
8 changes: 5 additions & 3 deletions pandas/tests/indexes/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,9 @@ def test_constructor_overflow_int64(self):
with tm.assert_raises_regex(OverflowError, msg):
Index([np.iinfo(np.uint64).max - 1], dtype="int64")

@pytest.mark.xfail(reason="see gh-21311: Index "
"doesn't enforce dtype argument")
@pytest.mark.xfail(reason="see GH#21311: Index "
"doesn't enforce dtype argument",
strict=True)
def test_constructor_cast(self):
msg = "could not convert string to float"
with tm.assert_raises_regex(ValueError, msg):
Expand Down Expand Up @@ -1455,7 +1456,8 @@ def test_slice_float_locs(self):
assert index2.slice_locs(8.5, 1.5) == (2, 6)
assert index2.slice_locs(10.5, -1) == (0, n)

@pytest.mark.xfail(reason="Assertions were not correct - see GH 20915")
@pytest.mark.xfail(reason="Assertions were not correct - see GH#20915",
strict=True)
def test_slice_ints_with_floats_raises(self):
# int slicing with floats
# GH 4892, these are all TypeErrors
Expand Down
3 changes: 2 additions & 1 deletion pandas/tests/indexes/test_numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ def test_rpow_float(self):
result = 2.0**idx
tm.assert_index_equal(result, expected)

@pytest.mark.xfail(reason='GH#19252 Series has no __rdivmod__')
@pytest.mark.xfail(reason='GH#19252 Series has no __rdivmod__',
strict=True)
def test_divmod_series(self):
idx = self.create_index()

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/io/formats/test_to_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def test_to_csv_string_array_ascii(self):
with open(path, 'r') as f:
assert f.read() == expected_ascii

@pytest.mark.xfail
@pytest.mark.xfail(strict=True)
def test_to_csv_string_array_utf8(self):
# GH 10813
str_array = [{'names': ['foo', 'bar']}, {'names': ['baz', 'qux']}]
Expand Down
12 changes: 9 additions & 3 deletions pandas/tests/io/json/test_json_table_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,10 @@ def test_mi_falsey_name(self):
class TestTableOrientReader(object):

@pytest.mark.parametrize("index_nm", [
None, "idx", pytest.param("index", marks=pytest.mark.xfail),
None,
"idx",
pytest.param("index",
marks=pytest.mark.xfail(strict=True)),
'level_0'])
@pytest.mark.parametrize("vals", [
{'ints': [1, 2, 3, 4]},
Expand All @@ -504,7 +507,8 @@ class TestTableOrientReader(object):
{'categoricals': pd.Series(pd.Categorical(['a', 'b', 'c', 'c']))},
{'ordered_cats': pd.Series(pd.Categorical(['a', 'b', 'c', 'c'],
ordered=True))},
pytest.param({'floats': [1., 2., 3., 4.]}, marks=pytest.mark.xfail),
pytest.param({'floats': [1., 2., 3., 4.]},
marks=pytest.mark.xfail(strict=True)),
{'floats': [1.1, 2.2, 3.3, 4.4]},
{'bools': [True, False, False, True]}])
def test_read_json_table_orient(self, index_nm, vals, recwarn):
Expand Down Expand Up @@ -562,7 +566,9 @@ def test_multiindex(self, index_names):
tm.assert_frame_equal(df, result)

@pytest.mark.parametrize("strict_check", [
pytest.param(True, marks=pytest.mark.xfail), False])
pytest.param(True, marks=pytest.mark.xfail(strict=True)),
False
])
def test_empty_frame_roundtrip(self, strict_check):
# GH 21287
df = pd.DataFrame([], columns=['a', 'b', 'c'])
Expand Down
3 changes: 2 additions & 1 deletion pandas/tests/io/test_excel.py
Original file line number Diff line number Diff line change
Expand Up @@ -2227,7 +2227,8 @@ def check_called(func):
pytest.param('xlwt',
marks=pytest.mark.xfail(reason='xlwt does not support '
'openpyxl-compatible '
'style dicts')),
'style dicts',
strict=True)),
'xlsxwriter',
'openpyxl',
])
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 @@ -216,7 +216,8 @@ def test_options_get_engine(fp, pa):


@pytest.mark.xfail(is_platform_windows() or is_platform_mac(),
reason="reading pa metadata failing on Windows/mac")
reason="reading pa metadata failing on Windows/mac",
strict=True)
def test_cross_engine_pa_fp(df_cross_compat, pa, fp):
# cross-compat with differing reading/writing engines

Expand Down Expand Up @@ -383,7 +384,8 @@ def test_basic(self, pa, df_full):

check_round_trip(df, pa)

@pytest.mark.xfail(reason="pyarrow fails on this (ARROW-1883)")
@pytest.mark.xfail(reason="pyarrow fails on this (ARROW-1883)",
strict=True)
def test_basic_subset_columns(self, pa, df_full):
# GH18628

Expand Down
3 changes: 2 additions & 1 deletion pandas/tests/plotting/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,8 @@ def test_subplots_timeseries_y_axis(self):
testdata.plot(y="text")

@pytest.mark.xfail(reason='not support for period, categorical, '
'datetime_mixed_tz')
'datetime_mixed_tz',
strict=True)
def test_subplots_timeseries_y_axis_not_supported(self):
"""
This test will fail for:
Expand Down
1 change: 0 additions & 1 deletion pandas/tests/plotting/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ def test_parallel_coordinates(self, iris):
with tm.assert_produces_warning(FutureWarning):
parallel_coordinates(df, 'Name', colors=colors)

@pytest.mark.xfail(reason="unreliable test")
def test_parallel_coordinates_with_sorted_labels(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

hah!

""" For #15908 """
from pandas.plotting import parallel_coordinates
Expand Down
18 changes: 11 additions & 7 deletions pandas/tests/reshape/test_pivot.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,8 @@ def test_pivot_with_list_like_values_nans(self, values):
tm.assert_frame_equal(result, expected)

@pytest.mark.xfail(reason='MultiIndexed unstack with tuple names fails'
'with KeyError #19966')
'with KeyError GH#19966',
strict=True)
def test_pivot_with_multiindex(self):
# issue #17160
index = Index(data=[0, 1, 2, 3, 4, 5])
Expand Down Expand Up @@ -617,8 +618,9 @@ def test_margins_dtype(self):

tm.assert_frame_equal(expected, result)

@pytest.mark.xfail(reason='GH 17035 (len of floats is casted back to '
'floats)')
@pytest.mark.xfail(reason='GH#17035 (len of floats is casted back to '
'floats)',
strict=True)
def test_margins_dtype_len(self):
mi_val = list(product(['bar', 'foo'], ['one', 'two'])) + [('All', '')]
mi = MultiIndex.from_tuples(mi_val, names=('A', 'B'))
Expand Down Expand Up @@ -1102,8 +1104,9 @@ def test_pivot_table_margins_name_with_aggfunc_list(self):
expected = pd.DataFrame(table.values, index=ix, columns=cols)
tm.assert_frame_equal(table, expected)

@pytest.mark.xfail(reason='GH 17035 (np.mean of ints is casted back to '
'ints)')
@pytest.mark.xfail(reason='GH#17035 (np.mean of ints is casted back to '
'ints)',
strict=True)
def test_categorical_margins(self, observed):
# GH 10989
df = pd.DataFrame({'x': np.arange(8),
Expand All @@ -1117,8 +1120,9 @@ def test_categorical_margins(self, observed):
table = df.pivot_table('x', 'y', 'z', dropna=observed, margins=True)
tm.assert_frame_equal(table, expected)

@pytest.mark.xfail(reason='GH 17035 (np.mean of ints is casted back to '
'ints)')
@pytest.mark.xfail(reason='GH#17035 (np.mean of ints is casted back to '
'ints)',
strict=True)
def test_categorical_margins_category(self, observed):
df = pd.DataFrame({'x': np.arange(8),
'y': np.arange(8) // 4,
Expand Down
3 changes: 2 additions & 1 deletion pandas/tests/scalar/period/test_asfreq.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def test_asfreq_near_zero_weekly(self):
assert week2.asfreq('D', 'S') <= per2

@pytest.mark.xfail(reason='GH#19643 period_helper asfreq functions fail '
'to check for overflows')
'to check for overflows',
strict=True)
def test_to_timestamp_out_of_bounds(self):
# GH#19643, currently gives Timestamp('1754-08-30 22:43:41.128654848')
per = Period('0001-01-01', freq='B')
Expand Down
1 change: 0 additions & 1 deletion pandas/tests/scalar/period/test_period.py
Original file line number Diff line number Diff line change
Expand Up @@ -1443,7 +1443,6 @@ def test_period_immutable():
per.freq = 2 * freq


@pytest.mark.xfail(reason='GH#19834 Period parsing error')
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 @@ -2070,7 +2070,7 @@ def test_value_counts_with_nan(self):
"dtype",
["int_", "uint", "float_", "unicode_", "timedelta64[h]",
pytest.param("datetime64[D]",
marks=pytest.mark.xfail(reason="issue7996"))]
marks=pytest.mark.xfail(reason="GH#7996", strict=True))]
)
@pytest.mark.parametrize("is_ordered", [True, False])
def test_drop_duplicates_categorical_non_bool(self, dtype, is_ordered):
Expand Down
3 changes: 2 additions & 1 deletion pandas/tests/series/test_rank.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ def test_rank_signature(self):
'int64',
marks=pytest.mark.xfail(
reason="iNaT is equivalent to minimum value of dtype"
"int64 pending issue #16674")),
"int64 pending issue GH#16674",
strict=True)),
([NegInfinity(), '1', 'A', 'BA', 'Ba', 'C', Infinity()],
'object')
])
Expand Down
8 changes: 4 additions & 4 deletions pandas/tests/sparse/frame/test_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from pandas.util import testing as tm


@pytest.mark.xfail(reason='Wrong SparseBlock initialization '
'(GH 17386)')
@pytest.mark.xfail(reason='Wrong SparseBlock initialization (GH#17386)',
strict=True)
def test_quantile():
# GH 17386
data = [[1, 1], [2, 10], [3, 100], [np.nan, np.nan]]
Expand All @@ -22,8 +22,8 @@ def test_quantile():
tm.assert_sp_series_equal(result, sparse_expected)


@pytest.mark.xfail(reason='Wrong SparseBlock initialization '
'(GH 17386)')
@pytest.mark.xfail(reason='Wrong SparseBlock initialization (GH#17386)',
strict=True)
def test_quantile_multi():
# GH 17386
data = [[1, 1], [2, 10], [3, 100], [np.nan, np.nan]]
Expand Down
Loading