Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add tests for canonicalizing extras names in evaluate_marker #544

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion tests/test_requirements_file.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
import pathlib
import textwrap
from itertools import product

from fromager.requirements_file import RequirementType, parse_requirements_file
import pytest
from packaging.markers import Marker
from packaging.requirements import Requirement

from fromager.requirements_file import (
RequirementType,
evaluate_marker,
parse_requirements_file,
)


def test_get_requirements_requirements_file(tmp_path: pathlib.Path):
Expand Down Expand Up @@ -50,3 +59,15 @@ def test_compare_req_type():
# make sure they equal themselves
for r in RequirementType:
assert r == r


@pytest.mark.parametrize(
"parent_e,marker_e,extras_e", list(product(["b-c", "b_c", "B_C"], repeat=3))
)
def test_evaluate_marker_canonical_names(parent_e, marker_e, extras_e):
parent_req = Requirement(f"a[{parent_e}]")
req = Requirement("d")
marker = Marker(f"extra == '{marker_e}'")
req.marker = marker
extras = set([extras_e])
assert evaluate_marker(parent_req=parent_req, req=req, extras=extras)
Loading