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), )
import pytest from pipgrip.libs.semver import Version, VersionRange, VersionUnion, parse_constraint @pytest.mark.parametrize( "input_,constraint", [ ("*", VersionRange()), ("*.*", VersionRange()), ("v*.*", VersionRange()), ("*.x.*", VersionRange()), ("x.X.x.*", VersionRange()), # ('!=1.0.0', Constraint('!=', '1.0.0.0')), (">1.0.0", VersionRange(min=Version(1, 0, 0))), (">1.0.0rc1", VersionRange(min=Version(1, 0, 0, pre="rc1"))), ("<1.2.3", VersionRange(max=Version(1, 2, 3))), ("<1.2.3rc1", VersionRange(max=Version(1, 2, 3, pre="rc1"))), ("<=1.2.3", VersionRange(max=Version(1, 2, 3), include_max=True)), ("<=1.2.3rc1", VersionRange(max=Version(1, 2, 3, pre="rc1"), include_max=True)), ("<=1.2rc1", VersionRange(max=Version(1, 2, 0, pre="rc1"), include_max=True)), (">=1.2.3", VersionRange(min=Version(1, 2, 3), include_min=True)), (">=1.2.3rc1", VersionRange(min=Version(1, 2, 3, pre="rc1"), include_min=True)), ("=1.2.3", Version(1, 2, 3)), ("=1.2.3rc1", Version(1, 2, 3, pre="rc1")), ("1.2.3", Version(1, 2, 3)), ("1.2.3rc1", Version(1, 2, 3, pre="rc1")), ("=1.0", Version(1, 0, 0)),
def test_parse_constraint_multi(input_): assert parse_constraint(input_) == VersionRange(Version(2, 0, 0), Version(3, 0, 0), include_min=False, include_max=True)
import pytest from pipgrip.libs.semver import EmptyConstraint, Version, VersionRange from pipgrip.libs.semver.exceptions import ParseVersionError @pytest.mark.parametrize( "input,version", [ ("1.0.0", Version(1, 0, 0)), ("1", Version(1, 0, 0)), ("1.0", Version(1, 0, 0)), ("1b1", Version(1, 0, 0, pre="beta1")), ("1.0b1", Version(1, 0, 0, pre="beta1")), ("1.0.0b1", Version(1, 0, 0, pre="beta1")), ("1.0.0-b1", Version(1, 0, 0, pre="beta1")), ("1.0.0-beta.1", Version(1, 0, 0, pre="beta1")), ("1.0.0+1", Version(1, 0, 0, build="1")), ("1.0.0-1", Version(1, 0, 0, build="1")), ("1.0.0.0", Version(1, 0, 0)), ("1.0.0-post", Version(1, 0, 0)), ("1.0.0-post1", Version(1, 0, 0, build="1")), ("0.6c", Version(0, 6, 0, pre="rc0")), ("0.6pre", Version(0, 6, 0, pre="rc0")), ], ) def test_parse_valid(input, version): parsed = Version.parse(input) assert parsed == version assert parsed.text == input