Skip to content

Commit

Permalink
Consider tests[].python.python_version when linting for cfep25 on v1 (
Browse files Browse the repository at this point in the history
#2210)

* Consider `tests[].python.python_version` when linting for cfep25 on v1

* add news

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix

* add test

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
hadim and pre-commit-ci[bot] authored Jan 7, 2025
1 parent 4af390e commit d7c65d7
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
8 changes: 8 additions & 0 deletions conda_smithy/lint_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,14 @@ def run_conda_forge_specific(
test_reqs += (test_element.get("requirements") or {}).get(
"run"
) or []

if (
"python" in test_element
and test_element["python"].get("python_version") is not None
):
test_reqs.append(
f"python {test_element['python']['python_version']}"
)
else:
test_section = get_section(meta, "test", lints, recipe_version)
test_reqs = test_section.get("requires") or []
Expand Down
23 changes: 23 additions & 0 deletions news/v1_cfep25_test.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* <news item>

**Changed:**

* <news item>

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* Consider `tests[].python.python_version`` when linting for cfep25 on v1.

**Security:**

* <news item>
30 changes: 30 additions & 0 deletions tests/test_lint_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -3882,5 +3882,35 @@ def test_lint_recipe_v1_invalid_schema_version():
assert lints == ["Unsupported recipe.yaml schema version 2"]


def test_lint_recipe_v1_python_min_in_python_version():
with tempfile.TemporaryDirectory() as tmpdir:
with open(os.path.join(tmpdir, "recipe.yaml"), "w") as f:
f.write(
textwrap.dedent(
"""
package:
name: python
build:
noarch: python
requirements:
host:
- python ${{ python_min }}
run:
- python >=${{ python_min }}
tests:
- python:
imports:
- mypackage
python_version: ${{ python_min }}.*
"""
)
)
_, hints = linter.main(tmpdir, return_hints=True, conda_forge=True)
assert hints == []


if __name__ == "__main__":
unittest.main()

0 comments on commit d7c65d7

Please sign in to comment.