From e23194f925c86e4bac1bfe763cf0e98627dcb357 Mon Sep 17 00:00:00 2001 From: Wolf Vollprecht Date: Fri, 9 Aug 2024 20:21:23 +0200 Subject: [PATCH] fix tests --- conda_smithy/lint_recipe.py | 4 ++-- tests/test_lint_recipe.py | 14 +++++--------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/conda_smithy/lint_recipe.py b/conda_smithy/lint_recipe.py index 7044f3bc0..f1ffc7a3e 100644 --- a/conda_smithy/lint_recipe.py +++ b/conda_smithy/lint_recipe.py @@ -101,8 +101,8 @@ def lintify_forge_yaml(recipe_dir: str | None = None) -> (list, list): def lintify_meta_yaml( meta: Any, - recipe_dir : str | None = None, - conda_forge : bool = False, + recipe_dir: str | None = None, + conda_forge: bool = False, recipe_version: int = 0, ) -> Tuple[List[str], List[str]]: lints = [] diff --git a/tests/test_lint_recipe.py b/tests/test_lint_recipe.py index da2d5e6e6..3069073f9 100644 --- a/tests/test_lint_recipe.py +++ b/tests/test_lint_recipe.py @@ -717,7 +717,7 @@ def test_recipe_v1_test_section(self): self.assertIn(expected_message, lints) lints, hints = linter.lintify_meta_yaml( - {"tests": {"script": "sys"}}, recipe_version=1 + {"tests": [{"script": "sys"}]}, recipe_version=1 ) self.assertNotIn(expected_message, lints) @@ -774,12 +774,13 @@ def test_recipe_v1_test_section_with_recipe(self): ) self.assertIn(expected_message, lints) + # Note: v1 recipes don't have implicit "run_test.py" support with open(os.path.join(recipe_dir, "run_test.py"), "w") as fh: fh.write("# foo") lints, hints = linter.lintify_meta_yaml( {}, recipe_dir, recipe_version=1 ) - self.assertNotIn(expected_message, lints) + self.assertIn(expected_message, lints) def test_jinja2_vars(self): expected_message = ( @@ -2676,23 +2677,18 @@ def test_pin_compatible_in_run_exports_output(recipe_version: int): def test_v1_recipes(): - with get_recipe_in_dir( - "v1_recipes/recipe-no-lint.yaml" - ) as recipe_dir: + with get_recipe_in_dir("v1_recipes/recipe-no-lint.yaml") as recipe_dir: lints, hints = linter.main(str(recipe_dir), return_hints=True) assert not lints def test_v1_no_test(): - with get_recipe_in_dir( - "v1_recipes/recipe-no-tests.yaml" - ) as recipe_dir: + with get_recipe_in_dir("v1_recipes/recipe-no-tests.yaml") as recipe_dir: lints, hints = linter.main(str(recipe_dir), return_hints=True) print(lints) assert "The recipe must have some tests." in lints - def test_v1_package_name_version(): with get_recipe_in_dir( "v1_recipes/recipe-lint-name-version.yaml"