Commit dd444198 by DanCardin Committed by Sébastien Eustace

Ignore poorly formed distribution version values. (#917)

parent a29a456d
...@@ -196,7 +196,11 @@ class Version(VersionRange): ...@@ -196,7 +196,11 @@ class Version(VersionRange):
@classmethod @classmethod
def parse(cls, text): # type: (str) -> Version def parse(cls, text): # type: (str) -> Version
match = COMPLETE_VERSION.match(text) try:
match = COMPLETE_VERSION.match(text)
except TypeError:
match = None
if match is None: if match is None:
raise ParseVersionError('Unable to parse "{}".'.format(text)) raise ParseVersionError('Unable to parse "{}".'.format(text))
......
...@@ -3,6 +3,7 @@ import pytest ...@@ -3,6 +3,7 @@ import pytest
from poetry.semver import EmptyConstraint from poetry.semver import EmptyConstraint
from poetry.semver import Version from poetry.semver import Version
from poetry.semver import VersionRange from poetry.semver import VersionRange
from poetry.semver.exceptions import ParseVersionError
@pytest.mark.parametrize( @pytest.mark.parametrize(
...@@ -32,6 +33,12 @@ def test_parse_valid(input, version): ...@@ -32,6 +33,12 @@ def test_parse_valid(input, version):
assert parsed.text == input assert parsed.text == input
@pytest.mark.parametrize("input", [(None, "example")])
def test_parse_invalid(input):
with pytest.raises(ParseVersionError):
Version.parse(input)
def test_comparison(): def test_comparison():
versions = [ versions = [
"1.0.0-alpha", "1.0.0-alpha",
......
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