From d45cf397f279aff2e4d0af09bc5e9f4f205676f9 Mon Sep 17 00:00:00 2001 From: Alexander Beedie Date: Fri, 10 May 2024 11:24:32 +0400 Subject: [PATCH] tests(python): Update tests for new `connectorx` (now works with 3.12) --- py-polars/requirements-dev.txt | 4 +--- py-polars/tests/unit/io/database/test_read.py | 23 ++++++++----------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/py-polars/requirements-dev.txt b/py-polars/requirements-dev.txt index 5001fb8e4c38..6afb0dfb85a2 100644 --- a/py-polars/requirements-dev.txt +++ b/py-polars/requirements-dev.txt @@ -28,9 +28,7 @@ SQLAlchemy adbc_driver_manager; python_version >= '3.9' and platform_system != 'Windows' adbc_driver_sqlite; python_version >= '3.9' and platform_system != 'Windows' aiosqlite -# TODO: Remove version constraint for connectorx when Python 3.12 is supported: -# https://github.com/sfu-db/connector-x/issues/527 -connectorx; python_version <= '3.11' +connectorx kuzu # Cloud cloudpickle diff --git a/py-polars/tests/unit/io/database/test_read.py b/py-polars/tests/unit/io/database/test_read.py index 0f6a088f4a0d..105240bc2d3c 100644 --- a/py-polars/tests/unit/io/database/test_read.py +++ b/py-polars/tests/unit/io/database/test_read.py @@ -157,10 +157,6 @@ class ExceptionTestParams(NamedTuple): schema_overrides={"id": pl.UInt8}, ), id="uri: connectorx", - marks=pytest.mark.skipif( - sys.version_info > (3, 11), - reason="connectorx cannot be installed on Python 3.12 yet.", - ), ), pytest.param( *DatabaseReadTestParams( @@ -644,10 +640,6 @@ def test_read_database_exceptions( read_database(**params) -@pytest.mark.skipif( - sys.version_info > (3, 11), - reason="connectorx cannot be installed on Python 3.12 yet.", -) @pytest.mark.parametrize( "uri", [ @@ -656,11 +648,16 @@ def test_read_database_exceptions( ], ) def test_read_database_cx_credentials(uri: str) -> None: - # check that we masked the potential credentials leak; this isn't really - # our responsibility (ideally would be handled by connectorx), but we - # can reasonably mitigate the issue. - with pytest.raises(BaseException, match=r"fakedb://\*\*\*:\*\*\*@\w+"): - pl.read_database_uri("SELECT * FROM data", uri=uri) + if sys.version_info > (3, 11): + # slightly different error on more recent Python versions + with pytest.raises(RuntimeError, match=r"Source.*not supported"): + pl.read_database_uri("SELECT * FROM data", uri=uri, engine="connectorx") + else: + # check that we masked the potential credentials leak; this isn't really + # our responsibility (ideally would be handled by connectorx), but we + # can reasonably mitigate the issue. + with pytest.raises(BaseException, match=r"fakedb://\*\*\*:\*\*\*@\w+"): + pl.read_database_uri("SELECT * FROM data", uri=uri, engine="connectorx") @pytest.mark.write_disk()