From af2513573779ff93d9a96db516f3dd59da7cb6d7 Mon Sep 17 00:00:00 2001 From: "Axel H." Date: Thu, 14 Dec 2023 17:36:54 +0100 Subject: [PATCH 1/2] build(pdm): add test settings and expose test script --- pyproject.toml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 26fdddc..835e9b7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,6 +58,16 @@ dev = [ "pytest>=7.4.3", ] +[tool.pdm.scripts] +test = "pytest" + +[tool.pytest.ini_options] +addopts = "-ra" +testpaths = [ + "src/", + "tests/", +] + [tool.pyright] venvPath = "." venv = ".venv" From 95d19a586dfd4c785ac11c8e4febee0c0b85cbe0 Mon Sep 17 00:00:00 2001 From: "Axel H." Date: Thu, 14 Dec 2023 17:38:56 +0100 Subject: [PATCH 2/2] fix(markers): ensure `SingleMarker` handling works when environment does not have `extra` but is not empty --- src/dep_logic/markers/single.py | 2 +- tests/marker/test_evaluation.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/dep_logic/markers/single.py b/src/dep_logic/markers/single.py index 3f113f2..2c2f72b 100644 --- a/src/dep_logic/markers/single.py +++ b/src/dep_logic/markers/single.py @@ -46,7 +46,7 @@ def only(self, *marker_names: str) -> BaseMarker: def evaluate(self, environment: dict[str, str] | None = None) -> bool: pkg_marker = _Marker(str(self)) - if self.name != "extra" or not environment: + if self.name != "extra" or not environment or "extra" not in environment: return pkg_marker.evaluate(environment) extras = [extra] if isinstance(extra := environment["extra"], str) else extra assert isinstance(self, MarkerExpression) diff --git a/tests/marker/test_evaluation.py b/tests/marker/test_evaluation.py index c16ec5f..22ea587 100644 --- a/tests/marker/test_evaluation.py +++ b/tests/marker/test_evaluation.py @@ -107,6 +107,8 @@ def test_evaluates( # single extra ("extra != 'security'", {"extra": "quux"}, True), ("extra != 'security'", {"extra": "security"}, False), + ("extra != 'security'", {}, True), + ("extra != 'security'", {"platform_machine": "x86_64"}, True), # normalization ("extra == 'Security.1'", {"extra": "security-1"}, True), ("extra == 'a'", {}, False),