Skip to content

Commit

Permalink
tests: fix up mypy issues on tests
Browse files Browse the repository at this point in the history
  • Loading branch information
IndexSeek committed Dec 22, 2024
1 parent 3ebbb8c commit 2bd6913
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions pyiceberg/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def _load_yaml(directory: Optional[str]) -> Optional[RecursiveDict]:
return None

# Directories to search for the configuration file
# The current search order is: PYICEBERG_HOME, home directory, then current directory
search_dirs = [os.environ.get(PYICEBERG_HOME), os.path.expanduser("~"), os.getcwd()]

for directory in search_dirs:
Expand Down
17 changes: 11 additions & 6 deletions tests/utils/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# specific language governing permissions and limitations
# under the License.
import os
from typing import Any, Dict, Optional
from unittest import mock

import pytest
Expand Down Expand Up @@ -117,9 +118,13 @@ def test_from_configuration_files_get_typed_value(tmp_path_factory: pytest.TempP
],
)
def test_from_multiple_configuration_files(
monkeypatch: pytest.MonkeyPatch, tmp_path_factory: pytest.TempPathFactory, config_location, config_content, expected_result
):
def create_config_file(directory: str, content: dict) -> None:
monkeypatch: pytest.MonkeyPatch,
tmp_path_factory: pytest.TempPathFactory,
config_location: str,
config_content: Optional[Dict[str, Any]],
expected_result: Optional[Dict[str, Any]],
) -> None:
def create_config_file(directory: str, content: Optional[Dict[str, Any]]) -> None:
config_file_path = os.path.join(directory, ".pyiceberg.yaml")
with open(config_file_path, "w", encoding="utf-8") as file:
yaml_str = as_document(content).as_yaml() if content else ""
Expand All @@ -144,6 +149,6 @@ def create_config_file(directory: str, content: dict) -> None:
if config_location == "current":
monkeypatch.chdir(current_path)

assert (
Config()._from_configuration_files() == expected_result
), f"Unexpected configuration result for content: {config_content}"
assert Config()._from_configuration_files() == expected_result, (
f"Unexpected configuration result for content: {config_content}"
)

0 comments on commit 2bd6913

Please sign in to comment.