Skip to content

Commit

Permalink
tests(python): Update tests for new connectorx (now works with 3.12)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-beedie committed May 10, 2024
1 parent c4e8678 commit d45cf39
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
4 changes: 1 addition & 3 deletions py-polars/requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 10 additions & 13 deletions py-polars/tests/unit/io/database/test_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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",
[
Expand All @@ -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()
Expand Down

0 comments on commit d45cf39

Please sign in to comment.