Skip to content

Commit

Permalink
TST: tighten xfails (#38309)
Browse files Browse the repository at this point in the history
* TST: tighten xfails

* troubleshoot
  • Loading branch information
jbrockmendel authored Dec 5, 2020
1 parent 122ae44 commit 22dbef1
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 22 deletions.
25 changes: 10 additions & 15 deletions pandas/tests/arrays/test_datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import numpy as np
import pytest
import pytz

from pandas._libs import NaT, OutOfBoundsDatetime, Timestamp
from pandas.compat.numpy import np_version_under1p18
Expand Down Expand Up @@ -269,18 +268,16 @@ def test_searchsorted(self):
assert result == 10

@pytest.mark.parametrize("box", [None, "index", "series"])
def test_searchsorted_castable_strings(self, arr1d, box):
def test_searchsorted_castable_strings(self, arr1d, box, request):
if isinstance(arr1d, DatetimeArray):
tz = arr1d.tz
if (
tz is not None
and tz is not pytz.UTC
and not isinstance(tz, pytz._FixedOffset)
):
ts1, ts2 = arr1d[1:3]
if tz is not None and ts1.tz.tzname(ts1) != ts2.tz.tzname(ts2):
# If we have e.g. tzutc(), when we cast to string and parse
# back we get pytz.UTC, and then consider them different timezones
# so incorrectly raise.
pytest.xfail(reason="timezone comparisons inconsistent")
mark = pytest.mark.xfail(reason="timezone comparisons inconsistent")
request.node.add_marker(mark)

arr = arr1d
if box is None:
Expand Down Expand Up @@ -391,19 +388,17 @@ def test_setitem(self):
expected[:2] = expected[-2:]
tm.assert_numpy_array_equal(arr.asi8, expected)

def test_setitem_strs(self, arr1d):
def test_setitem_strs(self, arr1d, request):
# Check that we parse strs in both scalar and listlike
if isinstance(arr1d, DatetimeArray):
tz = arr1d.tz
if (
tz is not None
and tz is not pytz.UTC
and not isinstance(tz, pytz._FixedOffset)
):
ts1, ts2 = arr1d[-2:]
if tz is not None and ts1.tz.tzname(ts1) != ts2.tz.tzname(ts2):
# If we have e.g. tzutc(), when we cast to string and parse
# back we get pytz.UTC, and then consider them different timezones
# so incorrectly raise.
pytest.xfail(reason="timezone comparisons inconsistent")
mark = pytest.mark.xfail(reason="timezone comparisons inconsistent")
request.node.add_marker(mark)

# Setting list-like of strs
expected = arr1d.copy()
Expand Down
5 changes: 3 additions & 2 deletions pandas/tests/base/test_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,15 +328,16 @@ def test_array_multiindex_raises():
),
],
)
def test_to_numpy(array, expected, index_or_series_or_array):
def test_to_numpy(array, expected, index_or_series_or_array, request):
box = index_or_series_or_array
thing = box(array)

if array.dtype.name in ("Int64", "Sparse[int64, 0]") and box is pd.Index:
pytest.skip(f"No index type for {array.dtype}")

if array.dtype.name == "int64" and box is pd.array:
pytest.xfail("thing is Int64 and to_numpy() returns object")
mark = pytest.mark.xfail(reason="thing is Int64 and to_numpy() returns object")
request.node.add_marker(mark)

result = thing.to_numpy()
tm.assert_numpy_array_equal(result, expected)
Expand Down
6 changes: 4 additions & 2 deletions pandas/tests/indexes/test_numpy_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,16 @@ def test_numpy_ufuncs_basic(index, func):
@pytest.mark.parametrize(
"func", [np.isfinite, np.isinf, np.isnan, np.signbit], ids=lambda x: x.__name__
)
def test_numpy_ufuncs_other(index, func):
def test_numpy_ufuncs_other(index, func, request):
# test ufuncs of numpy, see:
# https://numpy.org/doc/stable/reference/ufuncs.html

if isinstance(index, (DatetimeIndex, TimedeltaIndex)):
if isinstance(index, DatetimeIndex) and index.tz is not None:
if func in [np.isfinite, np.isnan, np.isinf]:
pytest.xfail(reason="__array_ufunc__ is not defined")
if not np_version_under1p17:
mark = pytest.mark.xfail(reason="__array_ufunc__ is not defined")
request.node.add_marker(mark)

if not np_version_under1p18 and func in [np.isfinite, np.isinf, np.isnan]:
# numpy 1.18(dev) changed isinf and isnan to not raise on dt64/tfd64
Expand Down
9 changes: 6 additions & 3 deletions pandas/tests/series/test_arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,12 +756,15 @@ def test_align_date_objects_with_datetimeindex(self):
)
@pytest.mark.parametrize("box", [list, tuple, np.array, pd.Index, pd.Series, pd.array])
@pytest.mark.parametrize("flex", [True, False])
def test_series_ops_name_retention(flex, box, names, all_binary_operators):
def test_series_ops_name_retention(flex, box, names, all_binary_operators, request):
# GH#33930 consistent name retention
op = all_binary_operators

if op is ops.rfloordiv and box in [list, tuple]:
pytest.xfail("op fails because of inconsistent ndarray-wrapping GH#28759")
if op is ops.rfloordiv and box in [list, tuple] and not flex:
mark = pytest.mark.xfail(
reason="op fails because of inconsistent ndarray-wrapping GH#28759"
)
request.node.add_marker(mark)

left = Series(range(10), name=names[0])
right = Series(range(10), name=names[1])
Expand Down

0 comments on commit 22dbef1

Please sign in to comment.