diff --git a/.github/workflows/python-dev.yml b/.github/workflows/python-dev.yml index 38b1aa9ae7047..4ef5b16e71e71 100644 --- a/.github/workflows/python-dev.yml +++ b/.github/workflows/python-dev.yml @@ -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 @@ -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 @@ -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 diff --git a/pandas/tests/arrays/string_/test_string.py b/pandas/tests/arrays/string_/test_string.py index 5731f02430a9d..c6240600d3a05 100644 --- a/pandas/tests/arrays/string_/test_string.py +++ b/pandas/tests/arrays/string_/test_string.py @@ -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 @@ -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") diff --git a/pandas/tests/extension/test_sparse.py b/pandas/tests/extension/test_sparse.py index f0d3fb7ff9e1b..9c21f717573c1 100644 --- a/pandas/tests/extension/test_sparse.py +++ b/pandas/tests/extension/test_sparse.py @@ -13,6 +13,7 @@ be added to the array-specific tests in `pandas/tests/arrays/`. """ + import numpy as np import pytest diff --git a/pandas/tests/indexes/test_base.py b/pandas/tests/indexes/test_base.py index d7abaf0b5dfbe..af781f0b58f85 100644 --- a/pandas/tests/indexes/test_base.py +++ b/pandas/tests/indexes/test_base.py @@ -12,6 +12,7 @@ from pandas.compat import ( IS64, + PY310, np_datetime64_compat, ) from pandas.util._test_decorators import async_mark @@ -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) @@ -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]), diff --git a/pandas/tests/io/json/test_ujson.py b/pandas/tests/io/json/test_ujson.py index 805f6b8dbe461..57a6b214cec84 100644 --- a/pandas/tests/io/json/test_ujson.py +++ b/pandas/tests/io/json/test_ujson.py @@ -16,6 +16,7 @@ import pandas._libs.json as ujson from pandas.compat import ( IS64, + PY310, is_platform_windows, ) @@ -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 diff --git a/pandas/tests/reshape/test_get_dummies.py b/pandas/tests/reshape/test_get_dummies.py index 653ea88ed62ac..d33721c796efa 100644 --- a/pandas/tests/reshape/test_get_dummies.py +++ b/pandas/tests/reshape/test_get_dummies.py @@ -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 @@ -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 @@ -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] diff --git a/pandas/tests/test_algos.py b/pandas/tests/test_algos.py index 4df95d895e475..490052c793fdc 100644 --- a/pandas/tests/test_algos.py +++ b/pandas/tests/test_algos.py @@ -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 ( @@ -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: @@ -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 @@ -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)