diff --git a/bindings/python/Makefile b/bindings/python/Makefile index c36a1091dd..0e8b9632dc 100644 --- a/bindings/python/Makefile +++ b/bindings/python/Makefile @@ -15,12 +15,15 @@ # specific language governing permissions and limitations # under the License. - -install: - uv sync --group dev --no-install-project +.PHONY: build install test build: uv run maturin develop +# uv sync may remove local editable pyiceberg-core, so install rebuilds it afterwards. +install: + uv sync --group dev --no-install-project + $(MAKE) build + test: uv run --no-sync pytest diff --git a/bindings/python/pyproject.toml b/bindings/python/pyproject.toml index 38efa00b34..9f62b5716d 100644 --- a/bindings/python/pyproject.toml +++ b/bindings/python/pyproject.toml @@ -51,6 +51,11 @@ include = [ [tool.ruff.lint] ignore = ["F403", "F405"] +[tool.pytest.ini_options] +filterwarnings = [ + "error", +] + [dependency-groups] dev = [ "maturin>=1.0,<2.0", diff --git a/bindings/python/tests/conftest.py b/bindings/python/tests/conftest.py index 75ee3f36a3..db672c7335 100644 --- a/bindings/python/tests/conftest.py +++ b/bindings/python/tests/conftest.py @@ -25,6 +25,7 @@ import pytest from pydantic_core import to_json +from pyiceberg.utils.config import Config from pyiceberg.partitioning import PartitionField, PartitionSpec from pyiceberg.schema import Schema @@ -36,6 +37,20 @@ ) +@pytest.fixture(scope="session", autouse=True) +def isolate_pyiceberg_config() -> Generator[None, None, None]: + monkeypatch = pytest.MonkeyPatch() + with TemporaryDirectory() as empty_home_dir: + monkeypatch.setenv("HOME", empty_home_dir) + monkeypatch.setenv("PYICEBERG_HOME", empty_home_dir) + + import pyiceberg.catalog as catalog + + monkeypatch.setattr(catalog, "_ENV_CONFIG", Config()) + yield + monkeypatch.undo() + + @pytest.fixture(scope="session") def avro_schema_manifest_entry() -> Dict[str, Any]: return { diff --git a/bindings/python/tests/test_datafusion_table_provider.py b/bindings/python/tests/test_datafusion_table_provider.py index 915b787697..3b2d881e18 100644 --- a/bindings/python/tests/test_datafusion_table_provider.py +++ b/bindings/python/tests/test_datafusion_table_provider.py @@ -106,7 +106,7 @@ def test_register_iceberg_table_provider( ) ctx = SessionContext() - ctx.register_table_provider("test", iceberg_table_provider) + ctx.register_table("test", iceberg_table_provider) datafusion_table = ctx.table("test") assert datafusion_table is not None @@ -154,7 +154,7 @@ def __datafusion_table_provider__(self): ) ctx = SessionContext() - ctx.register_table_provider("test", iceberg_table) + ctx.register_table("test", iceberg_table) datafusion_table = ctx.table("test") assert datafusion_table is not None