From 5a4a757d7a3d0ba13aae124bd1a041b8764c4d30 Mon Sep 17 00:00:00 2001 From: geruh Date: Fri, 6 Feb 2026 18:29:26 -0800 Subject: [PATCH] fix: isolate tests from local pyiceberg config files --- tests/conftest.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index 801c1e86a9..c46704f9e3 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -40,6 +40,7 @@ TYPE_CHECKING, Any, ) +from unittest import mock import boto3 import pytest @@ -112,6 +113,20 @@ def pytest_collection_modifyitems(items: list[pytest.Item]) -> None: item.add_marker("unmarked") +@pytest.fixture(autouse=True, scope="session") +def _isolate_pyiceberg_config() -> None: + """Make test runs ignore your local PyIceberg config. + + Without this, tests will attempt to resolve a local ~/.pyiceberg.yaml while running pytest. + This replaces the global catalog config once at session start with an env-only config. + """ + import pyiceberg.catalog as _catalog_module + from pyiceberg.utils.config import Config + + with mock.patch.object(Config, "_from_configuration_files", return_value=None): + _catalog_module._ENV_CONFIG = Config() + + def pytest_addoption(parser: pytest.Parser) -> None: # S3 options parser.addoption(