Commit ea9726dc by Sébastien Eustace

Add support for disjunctive python constraint

parent d348518b
......@@ -17,7 +17,7 @@ python-versions = "*"
platform = "*"
[package.requirements]
python = ">= 2.7.0.0 < 2.8.0.0"
python = ">= 2.7.0.0, < 2.8.0.0"
[[package]]
name = "C"
......@@ -32,7 +32,7 @@ platform = "*"
D = "^1.2"
[package.requirements]
python = ">= 3.6.0.0 < 4.0.0.0"
python = ">= 3.6.0.0, < 4.0.0.0"
[[package]]
name = "D"
......@@ -44,7 +44,7 @@ python-versions = "*"
platform = "*"
[package.requirements]
python = ">= 3.6.0.0 < 4.0.0.0"
python = ">= 3.6.0.0, < 4.0.0.0"
[metadata]
python-versions = "~2.7 || ^3.4"
......
......@@ -63,6 +63,25 @@ def test_parse_constraints_wildcard(parser, input, min, max):
@pytest.mark.parametrize(
'input,min,max',
[
('!=v2.*', Constraint('<', '2.0.0.0'), Constraint('>=', '3.0.0.0')),
('!=2.*.*', Constraint('<', '2.0.0.0'), Constraint('>=', '3.0.0.0')),
('!=2.0.*', Constraint('<', '2.0.0.0'), Constraint('>=', '2.1.0.0')),
('!=0.*', None, Constraint('>=', '1.0.0.0')),
('!=0.*.*', None, Constraint('>=', '1.0.0.0')),
]
)
def test_parse_constraints_negative_wildcard(parser, input, min, max):
if min:
expected = MultiConstraint((min, max), conjunctive=False)
else:
expected = max
assert str(parser.parse_constraints(input)) == str(expected)
@pytest.mark.parametrize(
'input,min,max',
[
('~v1', Constraint('>=', '1.0.0.0'), Constraint('<', '2.0.0.0')),
('~1.0', Constraint('>=', '1.0.0.0'), Constraint('<', '1.1.0.0')),
('~1.0.0', Constraint('>=', '1.0.0.0'), Constraint('<', '1.1.0.0')),
......
......@@ -24,7 +24,7 @@ def test_poetry():
assert package.keywords == ["packaging", "dependency", "poetry"]
assert package.python_versions == '~2.7 || ^3.6'
assert str(package.python_constraint) == '>= 2.7.0.0 < 2.8.0.0 || >= 3.6.0.0 < 4.0.0.0'
assert str(package.python_constraint) == '>= 2.7.0.0, < 2.8.0.0 || >= 3.6.0.0, < 4.0.0.0'
dependencies = package.requires
cleo = dependencies[0]
......
from poetry.version.helpers import format_python_constraint
from poetry.semver.version_parser import VersionParser
def test_format_python_constraint():
parser = VersionParser()
constraint = parser.parse_constraints('~2.7 || ^3.6')
result = format_python_constraint(constraint)
assert result == '>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*'
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