diff --git a/conda_smithy/linters_meta_yaml.py b/conda_smithy/linters_meta_yaml.py index 51a72d4e8..2fb3b866b 100644 --- a/conda_smithy/linters_meta_yaml.py +++ b/conda_smithy/linters_meta_yaml.py @@ -920,7 +920,7 @@ def lint_recipe_dir_inside_example_dir( """ recipe_dir = extras.recipe_dir - if recipe_dir and "recipes/example/" in str(recipe_dir): + if recipe_dir and "recipes/example/" in str(recipe_dir) + "/": return LintsHints.lint( "Please move the recipe out of the example dir and " "into its own dir." diff --git a/conda_smithy/linting_utils.py b/conda_smithy/linting_utils.py index 5db8ff34d..03b64ef48 100644 --- a/conda_smithy/linting_utils.py +++ b/conda_smithy/linting_utils.py @@ -50,6 +50,11 @@ def __add__(self, other: Any) -> LintsHints: hints=self.hints + other.hints, ) + def __eq__(self, other: Any) -> bool: + if not isinstance(other, LintsHints): + return NotImplemented + return self.lints == other.lints and self.hints == other.hints + def append_lint(self, lint: str) -> None: if lint in self.lints: return diff --git a/tests/test_linters_meta_yaml.py b/tests/test_linters_meta_yaml.py index 1fd550dfd..7e9ba5134 100644 --- a/tests/test_linters_meta_yaml.py +++ b/tests/test_linters_meta_yaml.py @@ -1,10 +1,33 @@ import inspect +import unittest +from pathlib import Path from typing import Set, Callable from conda_smithy import linters_meta_yaml +from conda_smithy.linters_meta_yaml import MetaYamlLintExtras from conda_smithy.linting_utils import LintsHints +class TestLintersMetaYaml(unittest.TestCase): + def test_lint_recipe_dir_inside_example_dir_no_recipe_dir(self): + results = linters_meta_yaml.lint_recipe_dir_inside_example_dir( + {}, MetaYamlLintExtras(is_conda_forge=True) + ) + + self.assertEqual(results, LintsHints()) + + def test_lint_recipe_dir_inside_example_dir(self): + recipe_dir = Path("recipes") / "example" + + results = linters_meta_yaml.lint_recipe_dir_inside_example_dir( + {}, MetaYamlLintExtras(recipe_dir, is_conda_forge=True) + ) + + message = "Please move the recipe out of the example dir and into its own dir." + + self.assertIn(message, results.lints) + + def test_complete_linter_list(): module_linters: Set[Callable[..., LintsHints]] = set()