Commit 77618678 by Sébastien Eustace

Fix a possible error on some combinations of markers

parent c9b73e7b
# Change Log # Change Log
## [Unreleased]
### Fixed
- Fixed possible error on some combinations of markers.
## [0.12.3] - 2018-10-18 ## [0.12.3] - 2018-10-18
### Fixed ### Fixed
......
...@@ -139,22 +139,27 @@ def convert_markers(marker): ...@@ -139,22 +139,27 @@ def convert_markers(marker):
requirements = {} requirements = {}
def _group(_groups, or_=False): def _group(_groups, or_=False):
ors = {}
for group in _groups: for group in _groups:
if isinstance(group, tuple): if isinstance(group, list):
_group(group, or_=True)
else:
variable, op, value = group variable, op, value = group
group_name = str(variable) group_name = str(variable)
if group_name not in requirements: if group_name not in requirements:
requirements[group_name] = [[]] requirements[group_name] = []
elif or_:
requirements[group_name].append([]) if group_name not in ors:
ors[group_name] = or_
or_ = False if ors[group_name] or not requirements[group_name]:
requirements[group_name].append([])
requirements[group_name][-1].append((str(op), str(value))) requirements[group_name][-1].append((str(op), str(value)))
else:
_group(group, or_=True)
_group(groups) ors[group_name] = False
_group(groups, or_=True)
return requirements return requirements
......
from poetry.packages.utils.utils import convert_markers
from poetry.version.markers import parse_marker
def test_convert_markers():
marker = parse_marker(
'sys_platform == "win32" and python_version < "3.6" '
'or sys_platform == "win32" and python_version < "3.6" and python_version >= "3.3" '
'or sys_platform == "win32" and python_version < "3.3"'
)
converted = convert_markers(marker)
assert converted["python_version"] == [
[("<", "3.6")],
[("<", "3.6"), (">=", "3.3")],
[("<", "3.3")],
]
marker = parse_marker('python_version == "2.7" or python_version == "2.6"')
converted = convert_markers(marker)
assert converted["python_version"] == [[("==", "2.7")], [("==", "2.6")]]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment