Skip to content

Backport PR #41595 on branch 1.3.x (CI: Xfails on Python 3.10) #42297

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
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
11 changes: 9 additions & 2 deletions .github/workflows/python-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ on:
paths-ignore:
- "doc/**"

env:
PYTEST_WORKERS: "auto"
PANDAS_CI: 1
PATTERN: "not slow and not network and not clipboard"
COVERAGE: true

jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -32,7 +38,7 @@ jobs:
pip install git+https://github.com/numpy/numpy.git
pip install git+https://github.com/pytest-dev/pytest.git
pip install git+https://github.com/nedbat/coveragepy.git
pip install cython python-dateutil pytz hypothesis pytest-xdist
pip install cython python-dateutil pytz hypothesis pytest-xdist pytest-cov
pip list

- name: Build Pandas
Expand All @@ -46,7 +52,8 @@ jobs:

- name: Test with pytest
run: |
coverage run -m pytest -m 'not slow and not network and not clipboard' pandas
ci/run_tests.sh
# GH 41935
continue-on-error: true

- name: Publish test results
Expand Down
5 changes: 1 addition & 4 deletions pandas/tests/arrays/string_/test_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
This module tests the functionality of StringArray and ArrowStringArray.
Tests for the str accessors are in pandas/tests/strings/test_string_array.py
"""

import re

import numpy as np
import pytest

Expand Down Expand Up @@ -314,7 +311,7 @@ def test_astype_int(dtype):
tm.assert_numpy_array_equal(result, expected)

arr = pd.array(["1", pd.NA, "3"], dtype=dtype)
msg = re.escape("int() argument must be a string, a bytes-like object or a number")
msg = r"int\(\) argument must be a string, a bytes-like object or a( real)? number"
with pytest.raises(TypeError, match=msg):
arr.astype("int64")

Expand Down
1 change: 1 addition & 0 deletions pandas/tests/extension/test_sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
be added to the array-specific tests in `pandas/tests/arrays/`.

"""

import numpy as np
import pytest

Expand Down
21 changes: 20 additions & 1 deletion pandas/tests/indexes/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from pandas.compat import (
IS64,
PY310,
np_datetime64_compat,
)
from pandas.util._test_decorators import async_mark
Expand Down Expand Up @@ -992,7 +993,7 @@ def test_isin(self, values, index, expected):
result = index.isin(values)
tm.assert_numpy_array_equal(result, expected)

def test_isin_nan_common_object(self, nulls_fixture, nulls_fixture2):
def test_isin_nan_common_object(self, request, nulls_fixture, nulls_fixture2):
# Test cartesian product of null fixtures and ensure that we don't
# mangle the various types (save a corner case with PyPy)

Expand All @@ -1003,6 +1004,24 @@ def test_isin_nan_common_object(self, nulls_fixture, nulls_fixture2):
and math.isnan(nulls_fixture)
and math.isnan(nulls_fixture2)
):
if PY310:
if (
# Failing cases are
# np.nan, float('nan')
# float('nan'), np.nan
# float('nan'), float('nan')
# Since only float('nan'), np.nan is float
# Use not np.nan to identify float('nan')
nulls_fixture is np.nan
and nulls_fixture2 is not np.nan
or nulls_fixture is not np.nan
):
request.applymarker(
# This test is flaky :(
pytest.mark.xfail(
reason="Failing on Python 3.10 GH41940", strict=False
)
)
tm.assert_numpy_array_equal(
Index(["a", nulls_fixture]).isin([nulls_fixture2]),
np.array([False, True]),
Expand Down
17 changes: 16 additions & 1 deletion pandas/tests/io/json/test_ujson.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import pandas._libs.json as ujson
from pandas.compat import (
IS64,
PY310,
is_platform_windows,
)

Expand Down Expand Up @@ -248,7 +249,21 @@ def test_double_precision(self):
assert rounded_input == json.loads(output)
assert rounded_input == ujson.decode(output)

@pytest.mark.parametrize("invalid_val", [20, -1, "9", None])
@pytest.mark.parametrize(
"invalid_val",
[
20,
-1,
pytest.param(
"9",
marks=pytest.mark.xfail(PY310, reason="Failing on Python 3.10 GH41940"),
),
pytest.param(
None,
marks=pytest.mark.xfail(PY310, reason="Failing on Python 3.10 GH41940"),
),
],
)
def test_invalid_double_precision(self, invalid_val):
double_input = 30.12345678901234567890
expected_exception = ValueError if isinstance(invalid_val, int) else TypeError
Expand Down
5 changes: 5 additions & 0 deletions pandas/tests/reshape/test_get_dummies.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import numpy as np
import pytest

from pandas.compat import PY310

from pandas.core.dtypes.common import is_integer_dtype

import pandas as pd
Expand Down Expand Up @@ -428,6 +430,8 @@ def test_dataframe_dummies_unicode(self, get_dummies_kwargs, expected):
result = get_dummies(**get_dummies_kwargs)
tm.assert_frame_equal(result, expected)

# This is flaky on Python 3.10
@pytest.mark.xfail(PY310, reason="Failing on Python 3.10 GH41940", strict=False)
def test_get_dummies_basic_drop_first(self, sparse):
# GH12402 Add a new parameter `drop_first` to avoid collinearity
# Basic case
Expand Down Expand Up @@ -467,6 +471,7 @@ def test_get_dummies_basic_drop_first_one_level(self, sparse):
result = get_dummies(s_series_index, drop_first=True, sparse=sparse)
tm.assert_frame_equal(result, expected)

@pytest.mark.xfail(PY310, reason="Failing on Python 3.10 GH41940", strict=False)
def test_get_dummies_basic_drop_first_NA(self, sparse):
# Test NA handling together with drop_first
s_NA = ["a", "b", np.nan]
Expand Down
11 changes: 10 additions & 1 deletion pandas/tests/test_algos.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
algos as libalgos,
hashtable as ht,
)
from pandas.compat import np_array_datetime64_compat
from pandas.compat import (
PY310,
np_array_datetime64_compat,
)
import pandas.util._test_decorators as td

from pandas.core.dtypes.common import (
Expand Down Expand Up @@ -783,6 +786,8 @@ def test_different_nans(self):
expected = np.array([np.nan])
tm.assert_numpy_array_equal(result, expected)

# Flaky on Python 3.10 -> Don't make strict
@pytest.mark.xfail(PY310, reason="Failing on Python 3.10 GH41940", strict=False)
def test_first_nan_kept(self):
# GH 22295
# create different nans from bit-patterns:
Expand Down Expand Up @@ -988,6 +993,8 @@ def __hash__(self):
# different objects -> False
tm.assert_numpy_array_equal(algos.isin([a], [b]), np.array([False]))

# Flaky on Python 3.10 -> Don't make strict
@pytest.mark.xfail(PY310, reason="Failing on Python 3.10 GH41940", strict=False)
def test_different_nans(self):
# GH 22160
# all nans are handled as equivalent
Expand Down Expand Up @@ -1030,6 +1037,8 @@ def test_empty(self, empty):
result = algos.isin(vals, empty)
tm.assert_numpy_array_equal(expected, result)

# Flaky on Python 3.10 -> Don't make strict
@pytest.mark.xfail(PY310, reason="Failing on Python 3.10 GH41940", strict=False)
def test_different_nan_objects(self):
# GH 22119
comps = np.array(["nan", np.nan * 1j, float("nan")], dtype=object)
Expand Down