From d6730084ad9ff2c5050041025e114b78ec245adb Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Fri, 28 Jun 2019 14:22:19 -0500 Subject: [PATCH 01/14] un-xfail tests, xfail instead of skip, minor cleanup --- pandas/tests/computation/test_eval.py | 8 ++++---- pandas/tests/frame/test_analytics.py | 7 +++---- pandas/tests/groupby/test_categorical.py | 2 +- pandas/tests/indexes/datetimes/test_construction.py | 2 -- pandas/tests/indexes/datetimes/test_tools.py | 4 +++- pandas/tests/io/json/test_pandas.py | 1 + pandas/tests/scalar/period/test_period.py | 2 +- pandas/tests/series/test_arithmetic.py | 10 ++-------- 8 files changed, 15 insertions(+), 21 deletions(-) diff --git a/pandas/tests/computation/test_eval.py b/pandas/tests/computation/test_eval.py index ca78e2e40ec74..1562cc300e020 100644 --- a/pandas/tests/computation/test_eval.py +++ b/pandas/tests/computation/test_eval.py @@ -366,7 +366,7 @@ def check_single_invert_op(self, lhs, cmp1, rhs): parser=self.parser)) def check_compound_invert_op(self, lhs, cmp1, rhs): - skip_these = 'in', 'not in' + skip_these = ['in', 'not in'] ex = '~(lhs {0} rhs)'.format(cmp1) msg = (r"only list-like( or dict-like)? objects are allowed to be" @@ -1713,7 +1713,7 @@ def test_result_types(self): def test_result_types2(self): # xref https://github.com/pandas-dev/pandas/issues/12293 - pytest.skip("unreliable tests on complex128") + # at one point this was unreliable on compled128 # Did not test complex64 because DataFrame is converting it to # complex128. Due to https://github.com/pandas-dev/pandas/issues/10952 @@ -1793,14 +1793,14 @@ def test_no_new_globals(self, engine, parser): @td.skip_if_no_ne def test_invalid_engine(): - msg = 'Invalid engine \'asdf\' passed' + msg = "Invalid engine 'asdf' passed" with pytest.raises(KeyError, match=msg): pd.eval('x + y', local_dict={'x': 1, 'y': 2}, engine='asdf') @td.skip_if_no_ne def test_invalid_parser(): - msg = 'Invalid parser \'asdf\' passed' + msg = "Invalid parser 'asdf' passed" with pytest.raises(KeyError, match=msg): pd.eval('x + y', local_dict={'x': 1, 'y': 2}, parser='asdf') diff --git a/pandas/tests/frame/test_analytics.py b/pandas/tests/frame/test_analytics.py index 01a398584b5e1..ded5312286302 100644 --- a/pandas/tests/frame/test_analytics.py +++ b/pandas/tests/frame/test_analytics.py @@ -1585,10 +1585,9 @@ def test_any_all_bool_only(self): (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 + (np.all, {'A': pd.Series([10, 20], dtype='M8[ns]'), + 'B': pd.Series([10, 20], dtype='m8[ns]')}, True), ]) def test_any_all_np_func(self, func, data, expected): # GH 19976 diff --git a/pandas/tests/groupby/test_categorical.py b/pandas/tests/groupby/test_categorical.py index 58a43dc218d33..f5c58019c433c 100644 --- a/pandas/tests/groupby/test_categorical.py +++ b/pandas/tests/groupby/test_categorical.py @@ -207,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 diff --git a/pandas/tests/indexes/datetimes/test_construction.py b/pandas/tests/indexes/datetimes/test_construction.py index 56dfbfd485eb1..e0238e639c071 100644 --- a/pandas/tests/indexes/datetimes/test_construction.py +++ b/pandas/tests/indexes/datetimes/test_construction.py @@ -608,8 +608,6 @@ def test_constructor_with_int_tz(self, klass, box, tz, dtype): expected = klass([ts]) assert result == expected - # This is the desired future behavior - @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 diff --git a/pandas/tests/indexes/datetimes/test_tools.py b/pandas/tests/indexes/datetimes/test_tools.py index a971a1088860a..1c517d7cc9230 100644 --- a/pandas/tests/indexes/datetimes/test_tools.py +++ b/pandas/tests/indexes/datetimes/test_tools.py @@ -616,7 +616,9 @@ def test_to_datetime_tz_psycopg2(self, cache): @pytest.mark.parametrize( 'cache', [pytest.param(True, - marks=pytest.mark.skipif(True, reason="GH 18111")), + marks=pytest.mark.xfail( + reason="GH#18111 pd.unique treats 0 and False " + "as equivalent")), False]) def test_datetime_bool(self, cache): # GH13176 diff --git a/pandas/tests/io/json/test_pandas.py b/pandas/tests/io/json/test_pandas.py index a935a731ccba6..36c3e7b9d1fbd 100644 --- a/pandas/tests/io/json/test_pandas.py +++ b/pandas/tests/io/json/test_pandas.py @@ -1159,6 +1159,7 @@ def test_to_jsonl(self): assert result == expected assert_frame_equal(pd.read_json(result, lines=True), df) + # TODO: there is a near-identical test for pytables; can we share? def test_latin_encoding(self): # GH 13774 pytest.skip("encoding not implemented in .to_json(), " diff --git a/pandas/tests/scalar/period/test_period.py b/pandas/tests/scalar/period/test_period.py index 2a765086af403..5f14094162a93 100644 --- a/pandas/tests/scalar/period/test_period.py +++ b/pandas/tests/scalar/period/test_period.py @@ -1490,7 +1490,7 @@ def test_period_immutable(): # 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) + strict=True) def test_small_year_parsing(): per1 = Period('0001-01-07', 'D') assert per1.year == 1 diff --git a/pandas/tests/series/test_arithmetic.py b/pandas/tests/series/test_arithmetic.py index 43fcddea3d964..af6754b3b288f 100644 --- a/pandas/tests/series/test_arithmetic.py +++ b/pandas/tests/series/test_arithmetic.py @@ -25,7 +25,7 @@ class TestSeriesFlexArithmetic: True) ]) @pytest.mark.parametrize('opname', ['add', 'sub', 'mul', 'floordiv', - 'truediv', 'div', 'pow']) + 'truediv', 'pow']) def test_flex_method_equivalence(self, opname, ts): # check that Series.{opname} behaves like Series.__{opname}__, tser = tm.makeTimeSeries().rename('ts') @@ -34,15 +34,9 @@ def test_flex_method_equivalence(self, opname, ts): other = ts[1](tser) check_reverse = ts[2] - if opname == 'div': - pytest.skip('div test only for Py3') - op = getattr(Series, opname) - if op == 'div': - alt = operator.truediv - else: - alt = getattr(operator, opname) + alt = getattr(operator, opname) result = op(series, other) expected = alt(series, other) From ef9298e8563868186ecd93cf7e8403df8c2debc3 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Sat, 29 Jun 2019 11:23:41 -0500 Subject: [PATCH 02/14] revert --- pandas/tests/indexes/datetimes/test_construction.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandas/tests/indexes/datetimes/test_construction.py b/pandas/tests/indexes/datetimes/test_construction.py index e0238e639c071..56dfbfd485eb1 100644 --- a/pandas/tests/indexes/datetimes/test_construction.py +++ b/pandas/tests/indexes/datetimes/test_construction.py @@ -608,6 +608,8 @@ def test_constructor_with_int_tz(self, klass, box, tz, dtype): expected = klass([ts]) assert result == expected + # This is the desired future behavior + @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 From 843a78388960174c84beebf8f0dc274d7da87227 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Sat, 29 Jun 2019 12:01:45 -0500 Subject: [PATCH 03/14] lint --- pandas/tests/groupby/test_categorical.py | 2 -- pandas/tests/indexes/datetimes/test_tools.py | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/pandas/tests/groupby/test_categorical.py b/pandas/tests/groupby/test_categorical.py index f5c58019c433c..dd37f88688b28 100644 --- a/pandas/tests/groupby/test_categorical.py +++ b/pandas/tests/groupby/test_categorical.py @@ -4,8 +4,6 @@ import numpy as np import pytest -from pandas.compat import PY37 - import pandas as pd from pandas import ( Categorical, CategoricalIndex, DataFrame, Index, MultiIndex, Series, qcut) diff --git a/pandas/tests/indexes/datetimes/test_tools.py b/pandas/tests/indexes/datetimes/test_tools.py index 1c517d7cc9230..b28560f241c66 100644 --- a/pandas/tests/indexes/datetimes/test_tools.py +++ b/pandas/tests/indexes/datetimes/test_tools.py @@ -617,8 +617,8 @@ def test_to_datetime_tz_psycopg2(self, cache): 'cache', [pytest.param(True, marks=pytest.mark.xfail( - reason="GH#18111 pd.unique treats 0 and False " - "as equivalent")), + reason="GH#18111 pd.unique treats 0 and False " + "as equivalent")), False]) def test_datetime_bool(self, cache): # GH13176 From 6dd725f666d4d9ffc2fa2a14a70a2544dae32236 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Sun, 30 Jun 2019 09:11:47 -0500 Subject: [PATCH 04/14] Remove xfail --- pandas/tests/scalar/period/test_period.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/pandas/tests/scalar/period/test_period.py b/pandas/tests/scalar/period/test_period.py index 5f14094162a93..070f09cd30688 100644 --- a/pandas/tests/scalar/period/test_period.py +++ b/pandas/tests/scalar/period/test_period.py @@ -1488,9 +1488,6 @@ 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=True) def test_small_year_parsing(): per1 = Period('0001-01-07', 'D') assert per1.year == 1 From 6700ec638f7325ff4a5549b03c7e81d1c9f7232b Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Sun, 30 Jun 2019 09:12:57 -0500 Subject: [PATCH 05/14] typo fixup --- pandas/tests/computation/test_eval.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/computation/test_eval.py b/pandas/tests/computation/test_eval.py index 1562cc300e020..eba4f0c8c7e13 100644 --- a/pandas/tests/computation/test_eval.py +++ b/pandas/tests/computation/test_eval.py @@ -1713,7 +1713,7 @@ def test_result_types(self): def test_result_types2(self): # xref https://github.com/pandas-dev/pandas/issues/12293 - # at one point this was unreliable on compled128 + # at one point this was unreliable on complex128 # Did not test complex64 because DataFrame is converting it to # complex128. Due to https://github.com/pandas-dev/pandas/issues/10952 From 3ccf1b7c0c72a7d92c3e033e03761927b60a1703 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Wed, 3 Jul 2019 21:27:17 -0700 Subject: [PATCH 06/14] blackify --- pandas/tests/frame/test_analytics.py | 11 ++++++++--- pandas/tests/indexes/datetimes/test_tools.py | 15 ++++++++++----- pandas/tests/series/test_arithmetic.py | 4 +--- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/pandas/tests/frame/test_analytics.py b/pandas/tests/frame/test_analytics.py index 9572874970352..d70ef6ee6d841 100644 --- a/pandas/tests/frame/test_analytics.py +++ b/pandas/tests/frame/test_analytics.py @@ -1821,10 +1821,15 @@ 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), + ( + np.all, + { + "A": pd.Series([10, 20], dtype="M8[ns]"), + "B": pd.Series([10, 20], dtype="m8[ns]"), + }, + True, + ), ], ) def test_any_all_np_func(self, func, data, expected): diff --git a/pandas/tests/indexes/datetimes/test_tools.py b/pandas/tests/indexes/datetimes/test_tools.py index 908a315568ea8..ac467cb4bedec 100644 --- a/pandas/tests/indexes/datetimes/test_tools.py +++ b/pandas/tests/indexes/datetimes/test_tools.py @@ -743,11 +743,16 @@ def test_to_datetime_tz_psycopg2(self, cache): @pytest.mark.parametrize( "cache", - [pytest.param(True, - marks=pytest.mark.xfail( - reason="GH#18111 pd.unique treats 0 and False " - "as equivalent")), - False]) + [ + pytest.param( + True, + marks=pytest.mark.xfail( + reason="GH#18111 pd.unique treats 0 and False as equivalent" + ), + ), + False, + ], + ) def test_datetime_bool(self, cache): # GH13176 with pytest.raises(TypeError): diff --git a/pandas/tests/series/test_arithmetic.py b/pandas/tests/series/test_arithmetic.py index 23dd34c223261..89557445cafb4 100644 --- a/pandas/tests/series/test_arithmetic.py +++ b/pandas/tests/series/test_arithmetic.py @@ -20,9 +20,7 @@ class TestSeriesFlexArithmetic: (lambda x: x, lambda x: x * 2, False), (lambda x: x, lambda x: x[::2], False), (lambda x: x, lambda x: 5, True), - (lambda x: tm.makeFloatSeries(), - lambda x: tm.makeFloatSeries(), - True), + (lambda x: tm.makeFloatSeries(), lambda x: tm.makeFloatSeries(), True), ], ) @pytest.mark.parametrize( From c3d38e4502e41d7a22ca3e0e510a73c5021bbd43 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Mon, 8 Jul 2019 17:50:43 -0700 Subject: [PATCH 07/14] un-xfail --- pandas/tests/indexes/datetimes/test_tools.py | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/pandas/tests/indexes/datetimes/test_tools.py b/pandas/tests/indexes/datetimes/test_tools.py index c44cbe365a150..8db15709da35d 100644 --- a/pandas/tests/indexes/datetimes/test_tools.py +++ b/pandas/tests/indexes/datetimes/test_tools.py @@ -741,18 +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.xfail( - reason="GH#18111 pd.unique treats 0 and False as equivalent" - ), - ), - False, - ], - ) + @pytest.mark.parametrize("cache", [True, False]) def test_datetime_bool(self, cache): # GH13176 with pytest.raises(TypeError): From 16057a4539be718bea9f2e20934a9560a27697b1 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Mon, 8 Jul 2019 17:52:07 -0700 Subject: [PATCH 08/14] revert --- pandas/tests/series/test_arithmetic.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pandas/tests/series/test_arithmetic.py b/pandas/tests/series/test_arithmetic.py index 89557445cafb4..5b57b5ba2dbae 100644 --- a/pandas/tests/series/test_arithmetic.py +++ b/pandas/tests/series/test_arithmetic.py @@ -24,7 +24,7 @@ class TestSeriesFlexArithmetic: ], ) @pytest.mark.parametrize( - "opname", ["add", "sub", "mul", "floordiv", "truediv", "pow"] + "opname", ["add", "sub", "mul", "floordiv", "truediv", "div", "pow"] ) def test_flex_method_equivalence(self, opname, ts): # check that Series.{opname} behaves like Series.__{opname}__, @@ -34,8 +34,15 @@ def test_flex_method_equivalence(self, opname, ts): other = ts[1](tser) check_reverse = ts[2] + if opname == "div": + pytest.skip("div test only for Py3") + op = getattr(Series, opname) - alt = getattr(operator, opname) + + if op == "div": + alt = operator.truediv + else: + alt = getattr(operator, opname) result = op(series, other) expected = alt(series, other) From 64c8a4ade2f0739ae86dbbb90a3110ca97aee65f Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Fri, 2 Aug 2019 08:41:17 -0700 Subject: [PATCH 09/14] troubleshoot xfails --- pandas/tests/arithmetic/test_datetime64.py | 1 + pandas/tests/extension/test_datetime.py | 16 ---------------- .../tests/indexes/datetimes/test_construction.py | 4 +++- pandas/tests/io/formats/test_to_csv.py | 1 - pandas/tests/io/test_parquet.py | 6 ++++-- pandas/tests/plotting/test_datetimelike.py | 1 - pandas/tests/series/test_analytics.py | 2 +- pandas/tests/sparse/test_combine_concat.py | 2 +- pandas/tests/sparse/test_pivot.py | 2 +- 9 files changed, 11 insertions(+), 24 deletions(-) diff --git a/pandas/tests/arithmetic/test_datetime64.py b/pandas/tests/arithmetic/test_datetime64.py index cca6836acf626..0b17ece14cbd1 100644 --- a/pandas/tests/arithmetic/test_datetime64.py +++ b/pandas/tests/arithmetic/test_datetime64.py @@ -666,6 +666,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 ): diff --git a/pandas/tests/extension/test_datetime.py b/pandas/tests/extension/test_datetime.py index 9a7a43cff0c27..a60607d586ada 100644 --- a/pandas/tests/extension/test_datetime.py +++ b/pandas/tests/extension/test_datetime.py @@ -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 @@ -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 diff --git a/pandas/tests/indexes/datetimes/test_construction.py b/pandas/tests/indexes/datetimes/test_construction.py index 66a22ae7e9e46..88bc11c588673 100644 --- a/pandas/tests/indexes/datetimes/test_construction.py +++ b/pandas/tests/indexes/datetimes/test_construction.py @@ -759,6 +759,8 @@ 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): @@ -766,7 +768,7 @@ def test_construction_int_rountrip(self, tz_naive_fixture): # 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): diff --git a/pandas/tests/io/formats/test_to_csv.py b/pandas/tests/io/formats/test_to_csv.py index c6485ff21bcfb..ee236a8253b01 100644 --- a/pandas/tests/io/formats/test_to_csv.py +++ b/pandas/tests/io/formats/test_to_csv.py @@ -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"]}] diff --git a/pandas/tests/io/test_parquet.py b/pandas/tests/io/test_parquet.py index a04fb9fd50257..d634859e72d7b 100644 --- a/pandas/tests/io/test_parquet.py +++ b/pandas/tests/io/test_parquet.py @@ -33,6 +33,10 @@ except ImportError: _HAVE_FASTPARQUET = False +pytestmark = pytest.mark.filterwarnings( + "ignore:RangeIndex.* is deprecated:DeprecationWarning" +) + # setup engines & skips @pytest.fixture( @@ -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 diff --git a/pandas/tests/plotting/test_datetimelike.py b/pandas/tests/plotting/test_datetimelike.py index e3bc3d452f038..69070ea11e478 100644 --- a/pandas/tests/plotting/test_datetimelike.py +++ b/pandas/tests/plotting/test_datetimelike.py @@ -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() diff --git a/pandas/tests/series/test_analytics.py b/pandas/tests/series/test_analytics.py index 32d32a5d14fb2..3a5a387b919be 100644 --- a/pandas/tests/series/test_analytics.py +++ b/pandas/tests/series/test_analytics.py @@ -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) ), ], ) diff --git a/pandas/tests/sparse/test_combine_concat.py b/pandas/tests/sparse/test_combine_concat.py index d7295c4bfe5f0..c553cd3fd1a7a 100644 --- a/pandas/tests/sparse/test_combine_concat.py +++ b/pandas/tests/sparse/test_combine_concat.py @@ -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 diff --git a/pandas/tests/sparse/test_pivot.py b/pandas/tests/sparse/test_pivot.py index 85b899dfe76d5..4a22be30e776f 100644 --- a/pandas/tests/sparse/test_pivot.py +++ b/pandas/tests/sparse/test_pivot.py @@ -52,7 +52,7 @@ def test_pivot_table_with_nans(self): @pytest.mark.xfail( not _np_version_under1p17, reason="failing occasionally on numpy > 1.17", - strict=False, + strict=True, ) def test_pivot_table_multi(self): res_sparse = pd.pivot_table( From 334f6ea131da59664fc0c882a2749c8588bb84bf Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Fri, 2 Aug 2019 13:58:01 -0700 Subject: [PATCH 10/14] skip on older numpy --- pandas/tests/frame/test_analytics.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandas/tests/frame/test_analytics.py b/pandas/tests/frame/test_analytics.py index 5c8b11e7adb48..e99208ac78e15 100644 --- a/pandas/tests/frame/test_analytics.py +++ b/pandas/tests/frame/test_analytics.py @@ -1820,13 +1820,15 @@ def test_any_all_bool_only(self): (np.all, {"A": pd.Series([1, 2], dtype="category")}, True), (np.any, {"A": pd.Series([1, 2], dtype="category")}, 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")], ), ], ) From 1a1e6800e684a01e343dd061a092bb755492b516 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Fri, 2 Aug 2019 14:51:33 -0700 Subject: [PATCH 11/14] skip on windwos --- pandas/tests/computation/test_eval.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pandas/tests/computation/test_eval.py b/pandas/tests/computation/test_eval.py index d67f2ae25d7e9..c500760fa1390 100644 --- a/pandas/tests/computation/test_eval.py +++ b/pandas/tests/computation/test_eval.py @@ -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 - # at one point this was unreliable 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 From cef2c964c57ee3a58569421595cccdc46281c709 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Fri, 2 Aug 2019 14:58:57 -0700 Subject: [PATCH 12/14] conditional xfail --- pandas/compat/__init__.py | 1 + pandas/tests/scalar/period/test_period.py | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/pandas/compat/__init__.py b/pandas/compat/__init__.py index c9597505fa596..5ecd641fc68be 100644 --- a/pandas/compat/__init__.py +++ b/pandas/compat/__init__.py @@ -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" diff --git a/pandas/tests/scalar/period/test_period.py b/pandas/tests/scalar/period/test_period.py index e52e876ba61c3..d05629e5f72dd 100644 --- a/pandas/tests/scalar/period/test_period.py +++ b/pandas/tests/scalar/period/test_period.py @@ -11,6 +11,7 @@ from pandas._libs.tslibs.period import IncompatibleFrequency from pandas._libs.tslibs.timezones import dateutil_gettz, maybe_get_tz from pandas.compat.numpy import np_datetime64_compat +from pandas.compat import PY35 import pandas as pd from pandas import NaT, Period, Timedelta, Timestamp, offsets @@ -1581,5 +1582,15 @@ def test_period_immutable(): def test_small_year_parsing(): per1 = Period("0001-01-07", "D") - assert per1.year == 1 - assert per1.day == 7 + try: + assert per1.year == 1 + assert per1.day == 7 + except AssertionError: + # For reasons unknown, this is parsing as Period('0007-01-01', 'D') + # on both Linux and OSX py35 builds on Azure. I (brock) cannot + # reproduce locally on py35. + if PY35: + pytest.xfail( + reason="Parsing as Period('0007-01-01', 'D') on PY35 for reasons unknown." + ) + raise From cdc81c0fbeff3c82f286fb3755caac8464a4b479 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Fri, 2 Aug 2019 16:28:42 -0700 Subject: [PATCH 13/14] flake8 fixup --- pandas/tests/scalar/period/test_period.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandas/tests/scalar/period/test_period.py b/pandas/tests/scalar/period/test_period.py index d05629e5f72dd..38f991e72d60d 100644 --- a/pandas/tests/scalar/period/test_period.py +++ b/pandas/tests/scalar/period/test_period.py @@ -1591,6 +1591,7 @@ def test_small_year_parsing(): # reproduce locally on py35. if PY35: pytest.xfail( - reason="Parsing as Period('0007-01-01', 'D') on PY35 for reasons unknown." + reason="Parsing as Period('0007-01-01', 'D') on PY35 " + "for reasons unknown." ) raise From 916b1c6974d594f8856e5f22875649b908ad90e0 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Fri, 2 Aug 2019 16:33:06 -0700 Subject: [PATCH 14/14] conditional xfail --- pandas/tests/scalar/period/test_period.py | 20 ++++++-------------- pandas/tests/sparse/test_pivot.py | 6 ------ 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/pandas/tests/scalar/period/test_period.py b/pandas/tests/scalar/period/test_period.py index 38f991e72d60d..b57b817461788 100644 --- a/pandas/tests/scalar/period/test_period.py +++ b/pandas/tests/scalar/period/test_period.py @@ -10,8 +10,8 @@ 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.numpy import np_datetime64_compat from pandas.compat import PY35 +from pandas.compat.numpy import np_datetime64_compat import pandas as pd from pandas import NaT, Period, Timedelta, Timestamp, offsets @@ -1580,18 +1580,10 @@ def test_period_immutable(): per.freq = 2 * freq +@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") - try: - assert per1.year == 1 - assert per1.day == 7 - except AssertionError: - # For reasons unknown, this is parsing as Period('0007-01-01', 'D') - # on both Linux and OSX py35 builds on Azure. I (brock) cannot - # reproduce locally on py35. - if PY35: - pytest.xfail( - reason="Parsing as Period('0007-01-01', 'D') on PY35 " - "for reasons unknown." - ) - raise + assert per1.year == 1 + assert per1.day == 7 diff --git a/pandas/tests/sparse/test_pivot.py b/pandas/tests/sparse/test_pivot.py index 4a22be30e776f..880c1c55f9f79 100644 --- a/pandas/tests/sparse/test_pivot.py +++ b/pandas/tests/sparse/test_pivot.py @@ -2,7 +2,6 @@ import pytest import pandas as pd -from pandas import _np_version_under1p17 import pandas.util.testing as tm @@ -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=True, - ) def test_pivot_table_multi(self): res_sparse = pd.pivot_table( self.sparse, index="A", columns="B", values=["D", "E"]