Commit 0ed8dde1 by Sébastien Eustace

Fix parsing of wildcard constraints

parent 22cf4155
......@@ -60,7 +60,6 @@ def parse_single_constraint(constraint): # type: (str) -> VersionConstraint
high = version.stable.next_major
return VersionRange(version, high, include_min=True)
return VersionRange()
# PEP 440 Tilde range (~=)
m = TILDE_PEP440_CONSTRAINT.match(constraint)
......
......@@ -13,7 +13,7 @@ COMPLETE_VERSION = re.compile("(?i)" + _COMPLETE_VERSION)
CARET_CONSTRAINT = re.compile("(?i)^\^({})$".format(_COMPLETE_VERSION))
TILDE_CONSTRAINT = re.compile("(?i)^~(?!=)({})$".format(_COMPLETE_VERSION))
TILDE_PEP440_CONSTRAINT = re.compile("(?i)^~=({})$".format(_COMPLETE_VERSION))
X_CONSTRAINT = re.compile("^(!= ?|==)?v?(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:\.[xX*])+$")
X_CONSTRAINT = re.compile("^(!=|==)?\s*v?(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:\.[xX*])+$")
BASIC_CONSTRAINT = re.compile(
"(?i)^(<>|!=|>=?|<=?|==?)?\s*({})".format(_COMPLETE_VERSION)
)
......@@ -3,6 +3,7 @@ import pytest
from poetry.semver import parse_constraint
from poetry.semver import Version
from poetry.semver import VersionRange
from poetry.semver import VersionUnion
@pytest.mark.parametrize(
......@@ -113,6 +114,17 @@ def test_parse_constraint_multi(input):
@pytest.mark.parametrize(
"input",
[">=2.7,!=3.0.*,!=3.1.*", ">=2.7, !=3.0.*, !=3.1.*", ">= 2.7, != 3.0.*, != 3.1.*"],
)
def test_parse_constraint_multi_wilcard(input):
assert parse_constraint(input) == VersionUnion(
VersionRange(Version(2, 7, 0), Version(3, 0, 0), True, False),
VersionRange(Version(3, 2, 0), None, True, False),
)
@pytest.mark.parametrize(
"input,constraint",
[
(
......
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