diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 6410f2edd6175..2938ea6302057 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -30,56 +30,10 @@ jobs: # Prevent the include jobs from overriding other jobs pattern: [""] include: - - name: "Downstream Compat" - env_file: actions-311-downstream_compat.yaml - pattern: "not slow and not network and not single_cpu" - pytest_target: "pandas/tests/test_downstream.py" - - name: "Minimum Versions" - env_file: actions-39-minimum_versions.yaml - pattern: "not slow and not network and not single_cpu" - - name: "Locale: it_IT" - env_file: actions-311.yaml - pattern: "not slow and not network and not single_cpu" - extra_apt: "language-pack-it" - # Use the utf8 version as the default, it has no bad side-effect. - lang: "it_IT.utf8" - lc_all: "it_IT.utf8" - # Also install it_IT (its encoding is ISO8859-1) but do not activate it. - # It will be temporarily activated during tests with locale.setlocale - extra_loc: "it_IT" - - name: "Locale: zh_CN" - env_file: actions-311.yaml - pattern: "not slow and not network and not single_cpu" - extra_apt: "language-pack-zh-hans" - # Use the utf8 version as the default, it has no bad side-effect. - lang: "zh_CN.utf8" - lc_all: "zh_CN.utf8" - # Also install zh_CN (its encoding is gb2312) but do not activate it. - # It will be temporarily activated during tests with locale.setlocale - extra_loc: "zh_CN" - - name: "Copy-on-Write 3.9" - env_file: actions-39.yaml - pattern: "not slow and not network and not single_cpu" - pandas_copy_on_write: "1" - - name: "Copy-on-Write 3.10" - env_file: actions-310.yaml - pattern: "not slow and not network and not single_cpu" - pandas_copy_on_write: "1" - - name: "Copy-on-Write 3.11" - env_file: actions-311.yaml - pattern: "not slow and not network and not single_cpu" - pandas_copy_on_write: "1" - - name: "Pypy" + - name: "PyPy" env_file: actions-pypy-39.yaml pattern: "not slow and not network and not single_cpu" test_args: "--max-worker-restart 0" - - name: "Numpy Dev" - env_file: actions-311-numpydev.yaml - pattern: "not slow and not network and not single_cpu" - test_args: "-W error::DeprecationWarning -W error::FutureWarning" - - name: "Pyarrow Nightly" - env_file: actions-311-pyarrownightly.yaml - pattern: "not slow and not network and not single_cpu" fail-fast: false name: ${{ matrix.name || format('ubuntu-latest {0}', matrix.env_file) }} env: @@ -160,7 +114,7 @@ jobs: - name: Test (not single_cpu) uses: ./.github/actions/run-tests - if: ${{ matrix.name != 'Pypy' }} + if: ${{ matrix.name != 'PyPy' }} env: # Set pattern to not single_cpu if not already set PATTERN: ${{ env.PATTERN == '' && 'not single_cpu' || matrix.pattern }} @@ -170,184 +124,6 @@ jobs: env: PATTERN: 'single_cpu' PYTEST_WORKERS: 0 - if: ${{ matrix.pattern == '' && (always() && steps.build.outcome == 'success')}} - - macos-windows: - timeout-minutes: 180 - strategy: - matrix: - os: [macos-latest, windows-latest] - env_file: [actions-39.yaml, actions-310.yaml, actions-311.yaml] - fail-fast: false - runs-on: ${{ matrix.os }} - name: ${{ format('{0} {1}', matrix.os, matrix.env_file) }} - concurrency: - # https://github.community/t/concurrecy-not-work-for-push/183068/7 - group: ${{ github.event_name == 'push' && github.run_number || github.ref }}-${{ matrix.env_file }}-${{ matrix.os }} - cancel-in-progress: true - env: - PANDAS_CI: 1 - PYTEST_TARGET: pandas - PATTERN: "not slow and not db and not network and not single_cpu" - # GH 47443: PYTEST_WORKERS > 0 crashes Windows builds with memory related errors - PYTEST_WORKERS: ${{ matrix.os == 'macos-latest' && 'auto' || '0' }} - - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Set up Conda - uses: ./.github/actions/setup-conda - with: - environment-file: ci/deps/${{ matrix.env_file }} - - - name: Build Pandas - uses: ./.github/actions/build_pandas - - - name: Test - uses: ./.github/actions/run-tests - - Linux-32-bit: - runs-on: ubuntu-22.04 - container: - image: quay.io/pypa/manylinux2014_i686 - options: --platform linux/386 - steps: - - name: Checkout pandas Repo - # actions/checkout does not work since it requires node - run: | - git config --global --add safe.directory $PWD - - if [ $GITHUB_EVENT_NAME != pull_request ]; then - git clone --recursive --branch=$GITHUB_REF_NAME https://github.com/${GITHUB_REPOSITORY}.git $GITHUB_WORKSPACE - git reset --hard $GITHUB_SHA - else - git clone --recursive https://github.com/${GITHUB_REPOSITORY}.git $GITHUB_WORKSPACE - git fetch origin $GITHUB_REF:my_ref_name - git checkout $GITHUB_BASE_REF - git -c user.email="you@example.com" merge --no-commit my_ref_name - fi - - name: Build environment and Run Tests - run: | - /opt/python/cp311-cp311/bin/python -m venv ~/virtualenvs/pandas-dev - . ~/virtualenvs/pandas-dev/bin/activate - python -m pip install --no-cache-dir -U pip wheel setuptools meson[ninja]==1.0.1 meson-python==0.13.1 - python -m pip install --no-cache-dir versioneer[toml] "cython<3.0.1" numpy python-dateutil pytz pytest>=7.3.2 pytest-xdist>=2.2.0 pytest-asyncio>=0.17 hypothesis>=6.46.1 - python -m pip install --no-cache-dir --no-build-isolation -e . - python -m pip list --no-cache-dir - export PANDAS_CI=1 - python -m pytest -m 'not slow and not network and not clipboard and not single_cpu' pandas --junitxml=test-data.xml - concurrency: - # https://github.community/t/concurrecy-not-work-for-push/183068/7 - group: ${{ github.event_name == 'push' && github.run_number || github.ref }}-32bit - cancel-in-progress: true - - Linux-Musl: - runs-on: ubuntu-22.04 - container: - image: quay.io/pypa/musllinux_1_1_x86_64 - steps: - - name: Checkout pandas Repo - # actions/checkout does not work since it requires node - run: | - git config --global --add safe.directory $PWD - - if [ $GITHUB_EVENT_NAME != pull_request ]; then - git clone --recursive --branch=$GITHUB_REF_NAME https://github.com/${GITHUB_REPOSITORY}.git $GITHUB_WORKSPACE - git reset --hard $GITHUB_SHA - else - git clone --recursive https://github.com/${GITHUB_REPOSITORY}.git $GITHUB_WORKSPACE - git fetch origin $GITHUB_REF:my_ref_name - git checkout $GITHUB_BASE_REF - git -c user.email="you@example.com" merge --no-commit my_ref_name - fi - - name: Configure System Packages - run: | - apk update - apk add musl-locales - - name: Build environment - run: | - /opt/python/cp311-cp311/bin/python -m venv ~/virtualenvs/pandas-dev - . ~/virtualenvs/pandas-dev/bin/activate - python -m pip install --no-cache-dir -U pip wheel setuptools meson-python==0.13.1 meson[ninja]==1.0.1 - python -m pip install --no-cache-dir versioneer[toml] "cython<3.0.1" numpy python-dateutil pytz pytest>=7.3.2 pytest-xdist>=2.2.0 pytest-asyncio>=0.17 hypothesis>=6.46.1 - python -m pip install --no-cache-dir --no-build-isolation -e . - python -m pip list --no-cache-dir - - - name: Run Tests - run: | - . ~/virtualenvs/pandas-dev/bin/activate - export PANDAS_CI=1 - python -m pytest -m 'not slow and not network and not clipboard and not single_cpu' pandas --junitxml=test-data.xml - concurrency: - # https://github.community/t/concurrecy-not-work-for-push/183068/7 - group: ${{ github.event_name == 'push' && github.run_number || github.ref }}-musl - cancel-in-progress: true - - python-dev: - # This job may or may not run depending on the state of the next - # unreleased Python version. DO NOT DELETE IT. - # - # In general, this will remain frozen(present, but not running) until: - # - The next unreleased Python version has released beta 1 - # - This version should be available on GitHub Actions. - # - Our required build/runtime dependencies(numpy, pytz, Cython, python-dateutil) - # support that unreleased Python version. - # To unfreeze, comment out the ``if: false`` condition, and make sure you update - # the name of the workflow and Python version in actions/setup-python ``python-version:`` - # - # After it has been unfrozen, this file should remain unfrozen(present, and running) until: - # - The next Python version has been officially released. - # OR - # - Most/All of our optional dependencies support the next Python version AND - # - The next Python version has released a rc(we are guaranteed a stable ABI). - # To freeze this file, uncomment out the ``if: false`` condition, and migrate the jobs - # to the corresponding posix/windows-macos/sdist etc. workflows. - # Feel free to modify this comment as necessary. - #if: false # Uncomment this to freeze the workflow, comment it to unfreeze - defaults: - run: - shell: bash -eou pipefail {0} - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-22.04, macOS-latest, windows-latest] - - timeout-minutes: 180 - - concurrency: - #https://github.community/t/concurrecy-not-work-for-push/183068/7 - group: ${{ github.event_name == 'push' && github.run_number || github.ref }}-${{ matrix.os }}-${{ matrix.pytest_target }}-dev - cancel-in-progress: true - - env: - PYTEST_WORKERS: "auto" - PANDAS_CI: 1 - PATTERN: "not slow and not network and not clipboard and not single_cpu" - PYTEST_TARGET: pandas - - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Set up Python Dev Version - uses: actions/setup-python@v4 - with: - python-version: '3.12-dev' + if: ${{ (matrix.pattern == '' && (always() && steps.build.outcome == 'success')) || matrix.name == 'PyPy'}} - - name: Build Environment - run: | - python --version - python -m pip install --upgrade pip setuptools wheel meson[ninja]==1.0.1 meson-python==0.13.1 - python -m pip install --pre --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy - python -m pip install versioneer[toml] - python -m pip install python-dateutil pytz tzdata "cython<3.0.1" hypothesis>=6.46.1 pytest>=7.3.2 pytest-xdist>=2.2.0 pytest-cov pytest-asyncio>=0.17 - python -m pip install -ve . --no-build-isolation --no-index - python -m pip list - - name: Run Tests - uses: ./.github/actions/run-tests diff --git a/ci/deps/actions-pypy-39.yaml b/ci/deps/actions-pypy-39.yaml index 23c3706f43dad..f2f60d41d22a3 100644 --- a/ci/deps/actions-pypy-39.yaml +++ b/ci/deps/actions-pypy-39.yaml @@ -15,7 +15,7 @@ dependencies: # test dependencies - pytest>=7.3.2 - - pytest-cov + # - pytest-cov # Don't use coverage on PyPy, it is too slow - pytest-asyncio>=0.17.0 - pytest-xdist>=2.2.0 - hypothesis>=6.46.1 diff --git a/ci/run_tests.sh b/ci/run_tests.sh index 48ef21686a26f..1df767cca7fad 100755 --- a/ci/run_tests.sh +++ b/ci/run_tests.sh @@ -8,7 +8,10 @@ export PYTHONHASHSEED=$(python -c 'import random; print(random.randint(1, 429496 # May help reproduce flaky CI builds if set in subsequent runs echo PYTHONHASHSEED=$PYTHONHASHSEED -COVERAGE="-s --cov=pandas --cov-report=xml --cov-append --cov-config=pyproject.toml" +export IS_PYPY=$(python -c "import sys; print(sys.implementation.name == 'pypy')") +if [[ "$IS_PYPY" != "True" ]]; then + COVERAGE="-s --cov=pandas --cov-report=xml --cov-append --cov-config=pyproject.toml" +fi PYTEST_CMD="MESONPY_EDITABLE_VERBOSE=1 PYTHONDEVMODE=1 PYTHONWARNDEFAULTENCODING=1 pytest -r fEs -n $PYTEST_WORKERS --dist=loadfile $TEST_ARGS $COVERAGE $PYTEST_TARGET" diff --git a/pandas/_testing/__init__.py b/pandas/_testing/__init__.py index 73835252c0329..2d3859d8f58d9 100644 --- a/pandas/_testing/__init__.py +++ b/pandas/_testing/__init__.py @@ -8,7 +8,7 @@ import os import re import string -from sys import byteorder +from sys import byteorder, implementation from typing import ( TYPE_CHECKING, Callable, @@ -210,6 +210,9 @@ ] ] +IS_PYPY = implementation.name == 'pypy' + + if not pa_version_under7p0: import pyarrow as pa @@ -1127,6 +1130,7 @@ def shares_memory(left, right) -> bool: "iat", "iloc", "index_subclass_makers_generator", + "IS_PYPY", "loc", "makeBoolIndex", "makeCategoricalIndex", diff --git a/pandas/testing.py b/pandas/testing.py index 841b55df48556..f2044d51bc6b8 100644 --- a/pandas/testing.py +++ b/pandas/testing.py @@ -8,6 +8,7 @@ assert_frame_equal, assert_index_equal, assert_series_equal, + IS_PYPY, ) __all__ = [ @@ -15,4 +16,5 @@ "assert_frame_equal", "assert_series_equal", "assert_index_equal", + "IS_PYPY", ] diff --git a/pandas/tests/apply/test_invalid_arg.py b/pandas/tests/apply/test_invalid_arg.py index a3d9de5e78afb..2ef0d4a116d4b 100644 --- a/pandas/tests/apply/test_invalid_arg.py +++ b/pandas/tests/apply/test_invalid_arg.py @@ -220,7 +220,10 @@ def transform2(row): ) def test_agg_cython_table_raises_frame(df, func, expected, axis): # GH 21224 - msg = "can't multiply sequence by non-int of type 'str'" + if tm.IS_PYPY: + msg = "unsupported operand type(s) for" + else: + msg = "can't multiply sequence by non-int of type 'str'" warn = None if isinstance(func, str) else FutureWarning with pytest.raises(expected, match=msg): with tm.assert_produces_warning(warn, match="using DataFrame.cumprod"): @@ -246,6 +249,8 @@ def test_agg_cython_table_raises_frame(df, func, expected, axis): def test_agg_cython_table_raises_series(series, func, expected): # GH21224 msg = r"[Cc]ould not convert|can't multiply sequence by non-int of type" + if tm.IS_PYPY: + msg += "|unsupported operand type(s) for" if func == "median" or func is np.nanmedian or func is np.median: msg = r"Cannot convert \['a' 'b' 'c'\] to numeric" warn = None if isinstance(func, str) else FutureWarning diff --git a/pandas/tests/arithmetic/test_datetime64.py b/pandas/tests/arithmetic/test_datetime64.py index 34b526bf97408..c1f20b2b860ed 100644 --- a/pandas/tests/arithmetic/test_datetime64.py +++ b/pandas/tests/arithmetic/test_datetime64.py @@ -1302,7 +1302,8 @@ def test_dti_add_tick_tzaware(self, tz_aware_fixture, box_with_array): tm.assert_equal(roundtrip, dates) msg = "|".join( - ["bad operand type for unary -", "cannot subtract DatetimeArray"] + ["bad operand type for unary -", "cannot subtract DatetimeArray", + "unsupported operand type for unary"] # PyPy ) with pytest.raises(TypeError, match=msg): scalar - dates @@ -1919,7 +1920,10 @@ def test_datetime64_ops_nat(self): # subtraction tm.assert_series_equal(-NaT + datetime_series, nat_series_dtype_timestamp) - msg = "bad operand type for unary -: 'DatetimeArray'" + if tm.IS_PYPY: + msg = "unsupported operand type for unary" + else: + msg = "bad operand type for unary -: 'DatetimeArray'" with pytest.raises(TypeError, match=msg): -single_nat_dtype_datetime + datetime_series diff --git a/pandas/tests/arithmetic/test_period.py b/pandas/tests/arithmetic/test_period.py index 2a34566d2f9f5..106f1e39d342f 100644 --- a/pandas/tests/arithmetic/test_period.py +++ b/pandas/tests/arithmetic/test_period.py @@ -1007,7 +1007,10 @@ def test_pi_sub_intarray(self, int_holder): expected = PeriodIndex([Period("2014Q1"), Period("NaT")]) tm.assert_index_equal(result, expected) - msg = r"bad operand type for unary -: 'PeriodArray'" + if tm.IS_PYPY: + msg = "unsupported operand type for unary" + else: + msg = r"bad operand type for unary -: 'PeriodArray'" with pytest.raises(TypeError, match=msg): other - pi @@ -1043,6 +1046,7 @@ def test_parr_add_timedeltalike_minute_gt1(self, three_days, box_with_array): [ r"bad operand type for unary -: 'PeriodArray'", r"cannot subtract PeriodArray from timedelta64\[[hD]\]", + "unsupported operand type for unary", # PyPy ] ) with pytest.raises(TypeError, match=msg): @@ -1075,6 +1079,7 @@ def test_parr_add_timedeltalike_tick_gt1(self, three_days, freqstr, box_with_arr [ r"bad operand type for unary -: 'PeriodArray'", r"cannot subtract PeriodArray from timedelta64\[[hD]\]", + "unsupported operand type for unary", # PyPy ] ) with pytest.raises(TypeError, match=msg): diff --git a/pandas/tests/arrays/floating/test_arithmetic.py b/pandas/tests/arrays/floating/test_arithmetic.py index 056c22d8c1131..3e4d46b00991a 100644 --- a/pandas/tests/arrays/floating/test_arithmetic.py +++ b/pandas/tests/arrays/floating/test_arithmetic.py @@ -140,6 +140,7 @@ def test_error_invalid_values(data, all_arithmetic_operators): "ufunc '.*' not supported for the input types, and the inputs could not", "ufunc '.*' did not contain a loop with signature matching types", "Concatenation operation is not implemented for NumPy arrays", + r"unsupported operand type(s) for", # PyPy ] ) with pytest.raises(TypeError, match=msg): @@ -161,6 +162,7 @@ def test_error_invalid_values(data, all_arithmetic_operators): "not all arguments converted during string formatting", "can't multiply sequence by non-int of type 'float'", "ufunc 'subtract' cannot use operands with types dtype", + r"unsupported operand type(s) for", # PyPy ( "ufunc 'add' cannot use operands with types " rf"dtype\('{tm.ENDIAN}M8\[ns\]'\)" diff --git a/pandas/tests/computation/test_eval.py b/pandas/tests/computation/test_eval.py index 9c630e29ea8e6..3a42557f95cab 100644 --- a/pandas/tests/computation/test_eval.py +++ b/pandas/tests/computation/test_eval.py @@ -401,7 +401,10 @@ def test_frame_invert(self, engine, parser): with pytest.raises(ValueError, match="unknown type object"): pd.eval(expr, engine=engine, parser=parser) else: - msg = "bad operand type for unary ~: 'str'" + if tm.IS_PYPY: + msg = "unsupported operand type for unary" + else: + msg = "bad operand type for unary ~: 'str'" with pytest.raises(TypeError, match=msg): pd.eval(expr, engine=engine, parser=parser) @@ -448,7 +451,10 @@ def test_series_invert(self, engine, parser): with pytest.raises(ValueError, match="unknown type object"): pd.eval(expr, engine=engine, parser=parser) else: - msg = "bad operand type for unary ~: 'str'" + if tm.IS_PYPY: + msg = "unsupported operand type for unary" + else: + msg = "bad operand type for unary ~: 'str'" with pytest.raises(TypeError, match=msg): pd.eval(expr, engine=engine, parser=parser) @@ -541,7 +547,10 @@ def test_series_pos(self, lhs, engine, parser): tm.assert_series_equal(expect, result) def test_scalar_unary(self, engine, parser): - msg = "bad operand type for unary ~: 'float'" + if tm.IS_PYPY: + msg = "unsupported operand type for unary" + else: + msg = "bad operand type for unary ~: 'float'" with pytest.raises(TypeError, match=msg): pd.eval("~1.0", engine=engine, parser=parser) diff --git a/pandas/tests/frame/test_reductions.py b/pandas/tests/frame/test_reductions.py index e7b6a0c0b39b0..e487a3f82d5f5 100644 --- a/pandas/tests/frame/test_reductions.py +++ b/pandas/tests/frame/test_reductions.py @@ -177,10 +177,10 @@ def test_stat_op_api_float_string_frame(self, float_string_frame, axis, opname): if opname in ["var", "std", "sem", "skew", "kurt"]: msg = "could not convert string to float: 'bar'" elif opname == "product": - if axis == 1: - msg = "can't multiply sequence by non-int of type 'float'" + if tm.IS_PYPY: + msg = "unsupported operand type" else: - msg = "can't multiply sequence by non-int of type 'str'" + msg = "can't multiply sequence by non-int of type" elif opname == "sum": msg = r"unsupported operand type\(s\) for \+: 'float' and 'str'" elif opname == "mean": diff --git a/pandas/tests/frame/test_unary.py b/pandas/tests/frame/test_unary.py index 5e29d3c868983..5befb14109fcc 100644 --- a/pandas/tests/frame/test_unary.py +++ b/pandas/tests/frame/test_unary.py @@ -51,7 +51,8 @@ def test_neg_object(self, df, expected): def test_neg_raises(self, df): msg = ( "bad operand type for unary -: 'str'|" - r"bad operand type for unary -: 'DatetimeArray'" + r"bad operand type for unary -: 'DatetimeArray'|" + "unsupported operand type for unary" # PyPy ) with pytest.raises(TypeError, match=msg): (-df) @@ -131,9 +132,12 @@ def test_pos_object(self, df): def test_pos_object_raises(self, df): # GH#21380 if np_version_gte1p25: + if tm.IS_PYPY: + msg = "unsupported operand type for unary" + else: + msg = r"^bad operand type for unary \+: \'str\'$" with pytest.raises( - TypeError, match=r"^bad operand type for unary \+: \'str\'$" - ): + TypeError, match=msg): tm.assert_frame_equal(+df, df) else: tm.assert_series_equal(+df["a"], df["a"]) @@ -142,7 +146,10 @@ def test_pos_object_raises(self, df): "df", [pd.DataFrame({"a": pd.to_datetime(["2017-01-22", "1970-01-01"])})] ) def test_pos_raises(self, df): - msg = r"bad operand type for unary \+: 'DatetimeArray'" + if tm.IS_PYPY: + msg = "unsupported operand type for unary" + else: + msg = r"bad operand type for unary \+: 'DatetimeArray'" with pytest.raises(TypeError, match=msg): (+df) with pytest.raises(TypeError, match=msg): diff --git a/pandas/tests/groupby/test_filters.py b/pandas/tests/groupby/test_filters.py index 0bb7ad4fd274d..998a1e4bd5ad5 100644 --- a/pandas/tests/groupby/test_filters.py +++ b/pandas/tests/groupby/test_filters.py @@ -157,7 +157,10 @@ def test_filter_bad_shapes(): g_s.filter(f) f = lambda x: np.outer(x, x) - msg = "can't multiply sequence by non-int of type 'str'" + if tm.IS_PYPY: + msg = "unsupported operand type(s) for" + else: + msg = "can't multiply sequence by non-int of type 'str'" with pytest.raises(TypeError, match=msg): g_df.filter(f) msg = "the filter must return a boolean result" diff --git a/pandas/tests/libs/test_hashtable.py b/pandas/tests/libs/test_hashtable.py index b78e6426ca17f..4d0ba413abe36 100644 --- a/pandas/tests/libs/test_hashtable.py +++ b/pandas/tests/libs/test_hashtable.py @@ -2,7 +2,10 @@ from contextlib import contextmanager import re import struct -import tracemalloc +try: + import tracemalloc +except ModuleNotFoundError: + tracemalloc = None import numpy as np import pytest @@ -16,6 +19,8 @@ @contextmanager def activated_tracemalloc() -> Generator[None, None, None]: + if not tracemalloc: + pytest.skip("no tracemalloc available") tracemalloc.start() try: yield diff --git a/pandas/tests/resample/test_resample_api.py b/pandas/tests/resample/test_resample_api.py index 1b20a7b99d1d7..d7fdbe65ccd59 100644 --- a/pandas/tests/resample/test_resample_api.py +++ b/pandas/tests/resample/test_resample_api.py @@ -865,8 +865,8 @@ def test_end_and_end_day_origin( ("sum", False, {"cat": ["cat_1cat_2"], "num": [25]}), ("sum", lib.no_default, {"cat": ["cat_1cat_2"], "num": [25]}), ("prod", True, {"num": [100]}), - ("prod", False, "can't multiply sequence"), - ("prod", lib.no_default, "can't multiply sequence"), + ("prod", False, r"can't multiply sequence|unsupported operand type\(s\) for"), + ("prod", lib.no_default, r"can't multiply sequence|unsupported operand type\(s\) for"), ("min", True, {"num": [5]}), ("min", False, {"cat": ["cat_1"], "num": [5]}), ("min", lib.no_default, {"cat": ["cat_1"], "num": [5]}), diff --git a/pandas/tests/scalar/interval/test_interval.py b/pandas/tests/scalar/interval/test_interval.py index a02dbf0a0413f..0e5fbd88e8ce7 100644 --- a/pandas/tests/scalar/interval/test_interval.py +++ b/pandas/tests/scalar/interval/test_interval.py @@ -204,7 +204,8 @@ def test_math_mult(self, closed): with pytest.raises(TypeError, match=msg): interval * interval - msg = r"can\'t multiply sequence by non-int" + msg = (r"can\'t multiply sequence by non-int" + r"|unsupported operand type\(s\) for \*") with pytest.raises(TypeError, match=msg): interval * "foo" diff --git a/pandas/tests/scalar/timedelta/test_timedelta.py b/pandas/tests/scalar/timedelta/test_timedelta.py index f1d8acf47b29a..fcb1ffd6c430b 100644 --- a/pandas/tests/scalar/timedelta/test_timedelta.py +++ b/pandas/tests/scalar/timedelta/test_timedelta.py @@ -330,7 +330,10 @@ class TestTimedeltaUnaryOps: def test_invert(self): td = Timedelta(10, unit="d") - msg = "bad operand type for unary ~" + if tm.IS_PYPY: + msg = "unsupported operand type for unary" + else: + msg = "bad operand type for unary ~" with pytest.raises(TypeError, match=msg): ~td