diff --git a/poetry/version/markers.py b/poetry/version/markers.py index 777309ec053..f8437348c05 100644 --- a/poetry/version/markers.py +++ b/poetry/version/markers.py @@ -629,7 +629,7 @@ def __hash__(self): def __str__(self): return " or ".join( - str(m) for m in self._markers if not m.is_any() or m.is_empty() + str(m) for m in self._markers if not m.is_any() and not m.is_empty() ) def is_any(self): diff --git a/tests/version/test_markers.py b/tests/version/test_markers.py index e010dca44d3..98536e4e2c7 100644 --- a/tests/version/test_markers.py +++ b/tests/version/test_markers.py @@ -354,17 +354,32 @@ def test_marker_union_union_duplicates(): ) def test_marker_union_all_any(): - m = parse_marker('') + union = MarkerUnion( + parse_marker(""), + parse_marker(""), + ) - union = m.union(parse_marker('')) assert union.is_any() def test_marker_union_all_any(): - m = parse_marker("") + union = MarkerUnion( + parse_marker(""), + parse_marker(""), + ) - union = m.union(parse_marker("")) assert union.is_empty() +def test_marker_str_conversion_skips_empty_and_any(): + union = MarkerUnion( + parse_marker(""), + parse_marker('sys_platform == "darwin" or python_version <= "3.6" or os_name == "Windows"'), + parse_marker('') + ) + + assert str(union) == ( + 'sys_platform == "darwin" or python_version <= "3.6" or os_name == "Windows"' + ) + def test_intersect_compacts_constraints(): m = parse_marker('python_version < "4.0"')