Skip to content

Commit

Permalink
unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Joseph Kahn committed Nov 28, 2019
1 parent c9e5c4b commit fcfccf3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion poetry/version/markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
23 changes: 19 additions & 4 deletions tests/version/test_markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("<empty>")
union = MarkerUnion(
parse_marker("<empty>"),
parse_marker("<empty>"),
)

union = m.union(parse_marker("<empty>"))
assert union.is_empty()

def test_marker_str_conversion_skips_empty_and_any():
union = MarkerUnion(
parse_marker("<empty>"),
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"')

Expand Down

0 comments on commit fcfccf3

Please sign in to comment.