Skip to content

Commit 5a4a757

Browse files
committed
fix: isolate tests from local pyiceberg config files
1 parent 7e66ccb commit 5a4a757

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/conftest.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
TYPE_CHECKING,
4141
Any,
4242
)
43+
from unittest import mock
4344

4445
import boto3
4546
import pytest
@@ -112,6 +113,20 @@ def pytest_collection_modifyitems(items: list[pytest.Item]) -> None:
112113
item.add_marker("unmarked")
113114

114115

116+
@pytest.fixture(autouse=True, scope="session")
117+
def _isolate_pyiceberg_config() -> None:
118+
"""Make test runs ignore your local PyIceberg config.
119+
120+
Without this, tests will attempt to resolve a local ~/.pyiceberg.yaml while running pytest.
121+
This replaces the global catalog config once at session start with an env-only config.
122+
"""
123+
import pyiceberg.catalog as _catalog_module
124+
from pyiceberg.utils.config import Config
125+
126+
with mock.patch.object(Config, "_from_configuration_files", return_value=None):
127+
_catalog_module._ENV_CONFIG = Config()
128+
129+
115130
def pytest_addoption(parser: pytest.Parser) -> None:
116131
# S3 options
117132
parser.addoption(

0 commit comments

Comments
 (0)