Skip to content

TST: clean up skips and xfails #30441

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 6 commits into from
Dec 24, 2019
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
15 changes: 11 additions & 4 deletions pandas/tests/frame/methods/test_rank.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import numpy as np
import pytest

import pandas.util._test_decorators as td

from pandas import DataFrame, Series
import pandas.util.testing as tm

Expand All @@ -26,8 +28,10 @@ def method(self, request):
"""
return request.param

@td.skip_if_no_scipy
def test_rank(self, float_frame):
rankdata = pytest.importorskip("scipy.stats.rankdata")
Copy link
Member

Choose a reason for hiding this comment

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

Were these ever running before? I guess this isn't directly importable

Copy link
Member Author

Choose a reason for hiding this comment

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

AFAICT no. im working on a branch now to reduce how many skips we have so we can keep a closer eye on them

Copy link
Member

Choose a reason for hiding this comment

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

Great!

import scipy.stats # noqa:F401
from scipy.stats import rankdata

float_frame["A"][::2] = np.nan
float_frame["B"][::3] = np.nan
Expand Down Expand Up @@ -117,8 +121,10 @@ def test_rank_mixed_frame(self, float_string_frame):
expected = float_string_frame.rank(1, numeric_only=True)
tm.assert_frame_equal(result, expected)

@td.skip_if_no_scipy
def test_rank_na_option(self, float_frame):
rankdata = pytest.importorskip("scipy.stats.rankdata")
import scipy.stats # noqa:F401
from scipy.stats import rankdata

float_frame["A"][::2] = np.nan
float_frame["B"][::3] = np.nan
Expand Down Expand Up @@ -199,9 +205,10 @@ def test_rank_axis(self):
tm.assert_frame_equal(df.rank(axis=0), df.rank(axis="index"))
tm.assert_frame_equal(df.rank(axis=1), df.rank(axis="columns"))

@td.skip_if_no_scipy
def test_rank_methods_frame(self):
pytest.importorskip("scipy.stats.special")
rankdata = pytest.importorskip("scipy.stats.rankdata")
import scipy.stats # noqa:F401
from scipy.stats import rankdata

xs = np.random.randint(0, 21, (100, 26))
xs = (xs - 10.0) / 10.0
Expand Down
9 changes: 2 additions & 7 deletions pandas/tests/indexes/datetimes/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,15 +725,10 @@ def test_constructor_with_int_tz(self, klass, box, tz, dtype):
expected = klass([ts])
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
# GH 12619, GH#24559
tz = tz_naive_fixture

result = 1293858000000000000
expected = DatetimeIndex([result], tz=tz).asi8[0]
assert result == expected
Expand Down
6 changes: 2 additions & 4 deletions pandas/tests/indexes/datetimes/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,13 +720,11 @@ def test_to_datetime_utc_true_with_series_datetime_ns(self, cache, date, dtype):
tm.assert_series_equal(result, expected)

@pytest.mark.parametrize("cache", [True, False])
@td.skip_if_no("psycopg2")
def test_to_datetime_tz_psycopg2(self, cache):

# xref 8260
try:
import psycopg2
except ImportError:
pytest.skip("no psycopg2 installed")
import psycopg2

# misc cases
tz1 = psycopg2.tz.FixedOffsetTimezone(offset=-300, name=None)
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 @@ -101,7 +101,7 @@ def test_nulls(idx):
idx.isna()


@pytest.mark.xfail
@pytest.mark.xfail(reason="isna is not defined for MultiIndex")
def test_hasnans_isnans(idx):
# GH 11343, added tests for hasnans / isnans
index = idx.copy()
Expand Down
4 changes: 4 additions & 0 deletions pandas/tests/test_downstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ def test_oo_optimizable():
@tm.network
# Cython import warning
@pytest.mark.filterwarnings("ignore:can't:ImportWarning")
@pytest.mark.filterwarnings(
# patsy needs to update their imports
"ignore:Using or importing the ABCs from 'collections:DeprecationWarning"
)
def test_statsmodels():

statsmodels = import_module("statsmodels") # noqa
Expand Down
14 changes: 5 additions & 9 deletions pandas/tests/window/test_moments.py
Original file line number Diff line number Diff line change
Expand Up @@ -2150,23 +2150,19 @@ def test_rolling_corr_diff_length(self):
lambda x: x.rolling(win_type="boxcar", window=10, min_periods=5).mean(),
],
)
@td.skip_if_no_scipy
def test_rolling_functions_window_non_shrinkage(self, f):
# GH 7764
s = Series(range(4))
s_expected = Series(np.nan, index=s.index)
df = DataFrame([[1, 5], [3, 2], [3, 9], [-1, 0]], columns=["A", "B"])
df_expected = DataFrame(np.nan, index=df.index, columns=df.columns)

try:
s_result = f(s)
tm.assert_series_equal(s_result, s_expected)

df_result = f(df)
tm.assert_frame_equal(df_result, df_expected)
except (ImportError):
s_result = f(s)
tm.assert_series_equal(s_result, s_expected)

# scipy needed for rolling_window
pytest.skip("scipy not available")
df_result = f(df)
tm.assert_frame_equal(df_result, df_expected)

def test_rolling_functions_window_non_shrinkage_binary(self):

Expand Down