diff --git a/py-polars/pyproject.toml b/py-polars/pyproject.toml index ca1a7cc7e0b6..e181bd959425 100644 --- a/py-polars/pyproject.toml +++ b/py-polars/pyproject.toml @@ -250,6 +250,9 @@ filterwarnings = [ # TODO: Excel tests lead to unclosed file warnings # https://github.com/pola-rs/polars/issues/14466 "ignore:unclosed file.*:ResourceWarning", + # Ignore invalid warnings when running earlier versions of SQLAlchemy (we + # know they are invalid because our standard tests run the latest version) + "ignore:Deprecated API features detected.*:DeprecationWarning", ] xfail_strict = true diff --git a/py-polars/tests/unit/interchange/test_roundtrip.py b/py-polars/tests/unit/interchange/test_roundtrip.py index 13ee04d5c37d..9857dffe426c 100644 --- a/py-polars/tests/unit/interchange/test_roundtrip.py +++ b/py-polars/tests/unit/interchange/test_roundtrip.py @@ -11,6 +11,7 @@ from hypothesis import given import polars as pl +from polars._utils.various import parse_version from polars.testing import assert_frame_equal from polars.testing.parametric import dataframes @@ -277,8 +278,8 @@ def test_to_dataframe_pyarrow_boolean_midbyte_slice() -> None: @pytest.mark.skipif( - sys.version_info < (3, 9), - reason="Older versions of pandas do not implement the required conversions", + parse_version(pd.__version__) < (2, 2), + reason="Pandas versions < 2.2 do not implement the required conversions", ) def test_from_dataframe_pandas_timestamp_ns() -> None: df = pl.Series("a", [datetime(2000, 1, 1)], dtype=pl.Datetime("ns")).to_frame() diff --git a/py-polars/tests/unit/io/database/test_async.py b/py-polars/tests/unit/io/database/test_async.py index b6c2f6e070e0..b51a01c8e37e 100644 --- a/py-polars/tests/unit/io/database/test_async.py +++ b/py-polars/tests/unit/io/database/test_async.py @@ -5,9 +5,11 @@ from typing import TYPE_CHECKING, Any, Iterable, overload import pytest -from sqlalchemy.ext.asyncio import async_sessionmaker, create_async_engine +import sqlalchemy +from sqlalchemy.ext.asyncio import create_async_engine import polars as pl +from polars._utils.various import parse_version from polars.testing import assert_frame_equal if TYPE_CHECKING: @@ -66,9 +68,14 @@ async def query( return [{"result": self._mock_data, "status": "OK", "time": "32.083µs"}] +@pytest.mark.skipif( + parse_version(sqlalchemy.__version__) < (2, 0), + reason="SQLAlchemy 2.0+ required for async tests", +) def test_read_async(tmp_sqlite_db: Path) -> None: # confirm that we can load frame data from the core sqlalchemy async # primitives: AsyncConnection, AsyncEngine, and async_sessionmaker + from sqlalchemy.ext.asyncio import async_sessionmaker async_engine = create_async_engine(f"sqlite+aiosqlite:///{tmp_sqlite_db}") async_connection = async_engine.connect() @@ -111,6 +118,10 @@ async def _nested_async_test(tmp_sqlite_db: Path) -> pl.DataFrame: ) +@pytest.mark.skipif( + parse_version(sqlalchemy.__version__) < (2, 0), + reason="SQLAlchemy 2.0+ required for async tests", +) def test_read_async_nested(tmp_sqlite_db: Path) -> None: # this tests validates that we can handle nested async calls. without # the nested asyncio handling provided by `nest_asyncio` this test diff --git a/py-polars/tests/unit/io/database/test_read.py b/py-polars/tests/unit/io/database/test_read.py index ab42f7993fea..52c4d5345b6a 100644 --- a/py-polars/tests/unit/io/database/test_read.py +++ b/py-polars/tests/unit/io/database/test_read.py @@ -11,11 +11,13 @@ import pyarrow as pa import pytest +import sqlalchemy from sqlalchemy import Integer, MetaData, Table, create_engine, func, select from sqlalchemy.orm import sessionmaker from sqlalchemy.sql.expression import cast as alchemy_cast import polars as pl +from polars._utils.various import parse_version from polars.exceptions import UnsuitableSQLError from polars.io.database._arrow_registry import ARROW_DRIVER_REGISTRY from polars.testing import assert_frame_equal @@ -387,6 +389,8 @@ def test_read_database_parameterised(tmp_sqlite_db: Path) -> None: for conn in (alchemy_session, alchemy_engine, alchemy_conn, raw_conn): if alchemy_session is conn and param == "?": continue # alchemy session.execute() doesn't support positional params + if parse_version(sqlalchemy.__version__) < (2, 0) and param == ":n": + continue # skip for older sqlalchemy versions assert_frame_equal( expected_frame,