diff --git a/conda_smithy/utils.py b/conda_smithy/utils.py index b0be1a656..3461ad69d 100644 --- a/conda_smithy/utils.py +++ b/conda_smithy/utils.py @@ -97,6 +97,9 @@ def render_meta_yaml(text): pin_compatible=stub_compatible_pin, cdt=lambda *args, **kwargs: "cdt_stub", load_file_regex=lambda *args, **kwargs: defaultdict(lambda: ""), + load_file_data=lambda *args, **kwargs: defaultdict(lambda: ""), + load_setup_py_data=lambda *args, **kwargs: defaultdict(lambda: ""), + load_str_data=lambda *args, **kwargs: defaultdict(lambda: ""), datetime=datetime, time=time, target_platform="linux-64", diff --git a/news/PR1829_load-data-fun.rst b/news/PR1829_load-data-fun.rst new file mode 100644 index 000000000..b373f11a1 --- /dev/null +++ b/news/PR1829_load-data-fun.rst @@ -0,0 +1,23 @@ +**Added:** + +* Complete conda-build load data functions stubs PR #1829 + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* diff --git a/tests/test_lint_recipe.py b/tests/test_lint_recipe.py index 6bdfbefaa..c385f0be9 100644 --- a/tests/test_lint_recipe.py +++ b/tests/test_lint_recipe.py @@ -674,6 +674,57 @@ def test_jinja_load_file_regex(self): ) lints = linter.main(recipe_dir) + def test_jinja_load_file_data(self): + # Test that we can use load_file_data in a recipe. We don't care about + # the results here and/or the actual file data because the recipe linter + # renders conda-build functions to just function stubs to pass the linting. + # TODO: add *args and **kwargs for functions used to parse the file. + with tmp_directory() as recipe_dir: + with io.open(os.path.join(recipe_dir, "meta.yaml"), "w") as fh: + fh.write( + """ + {% set data = load_file_data("IDONTNEED", from_recipe_dir=True, recipe_dir=".") %} + package: + name: foo + version: {{ version }} + """ + ) + lints = linter.main(recipe_dir) + + def test_jinja_load_setup_py_data(self): + # Test that we can use load_setup_py_data in a recipe. We don't care about + # the results here and/or the actual file data because the recipe linter + # renders conda-build functions to just function stubs to pass the linting. + # TODO: add *args and **kwargs for functions used to parse the file. + with tmp_directory() as recipe_dir: + with io.open(os.path.join(recipe_dir, "meta.yaml"), "w") as fh: + fh.write( + """ + {% set data = load_setup_py_data("IDONTNEED", from_recipe_dir=True, recipe_dir=".") %} + package: + name: foo + version: {{ version }} + """ + ) + lints = linter.main(recipe_dir) + + def test_jinja_load_str_data(self): + # Test that we can use load_str_data in a recipe. We don't care about + # the results here and/or the actual file data because the recipe linter + # renders conda-build functions to just function stubs to pass the linting. + # TODO: add *args and **kwargs for functions used to parse the data. + with tmp_directory() as recipe_dir: + with io.open(os.path.join(recipe_dir, "meta.yaml"), "w") as fh: + fh.write( + """ + {% set data = load_str_data("IDONTNEED", "json") %} + package: + name: foo + version: {{ version }} + """ + ) + lints = linter.main(recipe_dir) + def test_jinja_os_sep(self): # Test that we can use os.sep in a recipe. with tmp_directory() as recipe_dir: