From 06d5a07a3efd599f2c82bc2adedf645191db4de1 Mon Sep 17 00:00:00 2001 From: nichmor Date: Thu, 25 Apr 2024 17:00:51 +0300 Subject: [PATCH] fix: API usage of loader --- pixi.toml | 3 +++ src/rattler_build_conda_compat/loader.py | 4 +++- tests/test_rattler_loader.py | 8 +++++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/pixi.toml b/pixi.toml index 9df6806..356666a 100644 --- a/pixi.toml +++ b/pixi.toml @@ -28,6 +28,9 @@ pytest = "*" syrupy = "*" ruff = "*" +[feature.test.tasks] +test = "pytest" + [environments] test = ["test"] \ No newline at end of file diff --git a/src/rattler_build_conda_compat/loader.py b/src/rattler_build_conda_compat/loader.py index 56d4472..28b5c12 100644 --- a/src/rattler_build_conda_compat/loader.py +++ b/src/rattler_build_conda_compat/loader.py @@ -1,4 +1,6 @@ from contextlib import contextmanager +from os import PathLike +from pathlib import Path import yaml from typing import Any, Union @@ -67,7 +69,7 @@ def construct_sequence(self, node: Any, deep: bool = False) -> Any: def load_yaml(content: Union[str, bytes]): - return yaml.load(content, Loader=RecipeLoader) + return yaml.load(content, Loader=yaml.BaseLoader) def remove_empty_keys(variant_dict): diff --git a/tests/test_rattler_loader.py b/tests/test_rattler_loader.py index 12b3e55..ee4d5ae 100644 --- a/tests/test_rattler_loader.py +++ b/tests/test_rattler_loader.py @@ -1,5 +1,5 @@ import yaml -from rattler_build_conda_compat.loader import parse_recipe_config_file, load_all_requirements +from rattler_build_conda_compat.loader import load_yaml, parse_recipe_config_file, load_all_requirements from pathlib import Path @@ -12,7 +12,9 @@ def test_load_variants(snapshot, unix_namespace): def test_load_all_requirements(): - recipe_path = Path("tests/data/recipe_requirements.yaml") + recipe_content = Path("tests/data/recipe_requirements.yaml").read_text() - content = load_all_requirements(recipe_path) + recipe_content = load_yaml(recipe_content) + + content = load_all_requirements(recipe_content) print(content)