Skip to content

Commit a4a467c

Browse files
committed
make polars optional for test
1 parent 4eca798 commit a4a467c

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

bindings/python/justfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import-check:
1414
uv run python -c "from pymongoarrow.lib import libbson_version"
1515

1616
benchmark *args:
17-
uv sync --dev --extra test
17+
uv sync --dev --extra test --extra test-polars
1818
uv run asv run -e --python=$(uv run python -c "import sys;print(sys.executable)") {{args}}
1919

2020
install:
@@ -23,7 +23,7 @@ install:
2323
uv run pre-commit install
2424

2525
test *args:
26-
uv sync --extra test
26+
uv sync --extra test --extra test-polars || uv sync --extra test
2727
uv run pytest {{args}}
2828

2929
lint:

bindings/python/pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ Source = "https://github.com/mongodb-labs/mongo-arrow/tree/main/bindings/python"
5151
Tracker = "https://jira.mongodb.org/projects/INTPYTHON/issues"
5252

5353
[project.optional-dependencies]
54-
test = ["pytz", "pytest", "polars"]
54+
test = ["pytz", "pytest"]
55+
test-polars = ["polars"]
5556

5657
[tool.setuptools]
5758
zip-safe = false

bindings/python/test/test_polars.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@
2222
from test.utils import AllowListEventListener
2323

2424
import bson
25-
import polars as pl
2625
import pyarrow as pa
27-
from polars.testing import assert_frame_equal
26+
import pytest
2827
from pyarrow import int32, int64
2928
from pymongo import DESCENDING, WriteConcern
3029
from pymongo.collection import Collection
@@ -40,6 +39,15 @@
4039
ObjectIdType,
4140
)
4241

42+
try:
43+
import polars as pl
44+
from polars.testing import assert_frame_equal
45+
except ImportError:
46+
pl = None
47+
48+
if pl is None:
49+
pytest.skip("Requires polars.", allow_module_level=True)
50+
4351

4452
class PolarsTestBase(unittest.TestCase):
4553
@classmethod

0 commit comments

Comments
 (0)