Skip to content

Commit

Permalink
add tests for cnf
Browse files Browse the repository at this point in the history
  • Loading branch information
radoering committed Dec 17, 2022
1 parent 5f22121 commit ea06285
Showing 1 changed file with 173 additions and 0 deletions.
173 changes: 173 additions & 0 deletions tests/version/test_markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from poetry.core.version.markers import MarkerUnion
from poetry.core.version.markers import MultiMarker
from poetry.core.version.markers import SingleMarker
from poetry.core.version.markers import cnf
from poetry.core.version.markers import dnf
from poetry.core.version.markers import parse_marker

Expand Down Expand Up @@ -1131,6 +1132,178 @@ def test_union_should_drop_markers_if_their_complement_is_present(
assert parse_marker(expected) == m


@pytest.mark.parametrize(
"scheme, marker, expected",
[
("empty", EmptyMarker(), EmptyMarker()),
("any", AnyMarker(), AnyMarker()),
(
"A_",
SingleMarker("python_version", ">=3.7"),
SingleMarker("python_version", ">=3.7"),
),
(
"AB_",
MultiMarker(
SingleMarker("python_version", ">=3.7"),
SingleMarker("python_version", "<3.9"),
),
MultiMarker(
SingleMarker("python_version", ">=3.7"),
SingleMarker("python_version", "<3.9"),
),
),
(
"A+B_",
MarkerUnion(
SingleMarker("python_version", "<3.7"),
SingleMarker("python_version", ">=3.9"),
),
MarkerUnion(
SingleMarker("python_version", "<3.7"),
SingleMarker("python_version", ">=3.9"),
),
),
(
"(A+B)(C+D)_",
MultiMarker(
MarkerUnion(
SingleMarker("python_version", ">=3.7"),
SingleMarker("sys_platform", "win32"),
),
MarkerUnion(
SingleMarker("python_version", "<3.9"),
SingleMarker("sys_platform", "linux"),
),
),
MultiMarker(
MarkerUnion(
SingleMarker("python_version", ">=3.7"),
SingleMarker("sys_platform", "win32"),
),
MarkerUnion(
SingleMarker("python_version", "<3.9"),
SingleMarker("sys_platform", "linux"),
),
),
),
(
"AB+AC_A(B+C)",
MarkerUnion(
MultiMarker(
SingleMarker("python_version", ">=3.7"),
SingleMarker("python_version", "<3.9"),
),
MultiMarker(
SingleMarker("python_version", ">=3.7"),
SingleMarker("sys_platform", "linux"),
),
),
MultiMarker(
SingleMarker("python_version", ">=3.7"),
MarkerUnion(
SingleMarker("python_version", "<3.9"),
SingleMarker("sys_platform", "linux"),
),
),
),
(
"A+BC_(A+B)(A+C)",
MarkerUnion(
SingleMarker("python_version", "<3.7"),
MultiMarker(
SingleMarker("python_version", ">=3.9"),
SingleMarker("sys_platform", "linux"),
),
),
MultiMarker(
MarkerUnion(
SingleMarker("python_version", "<3.7"),
SingleMarker("python_version", ">=3.9"),
),
MarkerUnion(
SingleMarker("python_version", "<3.7"),
SingleMarker("sys_platform", "linux"),
),
),
),
(
"(A+B(C+D))(E+F)_(A+B)(A+C+D)(E+F)",
MultiMarker(
MarkerUnion(
SingleMarker("python_version", ">=3.9"),
MultiMarker(
SingleMarker("implementation_name", "cpython"),
MarkerUnion(
SingleMarker("python_version", "<3.7"),
SingleMarker("python_version", ">=3.8"),
),
),
),
MarkerUnion(
SingleMarker("sys_platform", "win32"),
SingleMarker("sys_platform", "linux"),
),
),
MultiMarker(
MarkerUnion(
SingleMarker("python_version", ">=3.9"),
SingleMarker("implementation_name", "cpython"),
),
MarkerUnion(
SingleMarker("python_version", "<3.7"),
SingleMarker("python_version", ">=3.8"),
),
MarkerUnion(
SingleMarker("sys_platform", "win32"),
SingleMarker("sys_platform", "linux"),
),
),
),
(
"A(B+C)+(D+E)(F+G)_(A+D+E)(B+C+D+E)(A+F+G)(B+C+F+G)",
MarkerUnion(
MultiMarker(
SingleMarker("sys_platform", "!=win32"),
MarkerUnion(
SingleMarker("python_version", "<3.7"),
SingleMarker("python_version", ">=3.9"),
),
),
MultiMarker(
MarkerUnion(
SingleMarker("python_version", "<3.8"),
SingleMarker("python_version", ">=3.9"),
),
MarkerUnion(
SingleMarker("sys_platform", "!=linux"),
SingleMarker("python_version", ">=3.9"),
),
),
),
MultiMarker(
MarkerUnion(
SingleMarker("sys_platform", "!=win32"),
SingleMarker("python_version", "<3.8"),
SingleMarker("python_version", ">=3.9"),
),
MarkerUnion(
SingleMarker("python_version", "<3.8"),
SingleMarker("python_version", ">=3.9"),
),
MarkerUnion(
SingleMarker("python_version", "<3.7"),
SingleMarker("sys_platform", "!=linux"),
SingleMarker("python_version", ">=3.9"),
),
),
),
],
)
def test_cnf(scheme: str, marker: BaseMarker, expected: BaseMarker) -> None:
assert cnf(marker) == expected


@pytest.mark.parametrize(
"scheme, marker, expected",
[
Expand Down

0 comments on commit ea06285

Please sign in to comment.