示例#1
0
 def test_str(self):
     assert str(SemVer.parse('1')) == '1.0.0'
     assert str(SemVer.parse('1.2')) == '1.2.0'
     assert str(SemVer.parse('1.2.3')) == '1.2.3'
     assert str(SemVer.parse('1.2.3-pre')) == '1.2.3-pre'
     assert str(SemVer.parse('1.2.3+local')) == '1.2.3+local'
     assert str(SemVer.parse('1.2.3-pre+local')) == '1.2.3-pre+local'
示例#2
0
    def test_parse(self):
        version = SemVer.parse('1')
        self.check_version(version, 1, 0, 0, None, None)

        version = SemVer.parse('1.2')
        self.check_version(version, 1, 2, 0, None, None)

        version = SemVer.parse('1.2.3')
        self.check_version(version, 1, 2, 3, None, None)

        version = SemVer.parse('1.2.3-pre')
        self.check_version(version, 1, 2, 3, 'pre', None)

        version = SemVer.parse('1.2.3+local')
        self.check_version(version, 1, 2, 3, None, 'local')

        version = SemVer.parse('1.2.3-pre+local')
        self.check_version(version, 1, 2, 3, 'pre', 'local')
示例#3
0
def test_bump_no_args_retains_local():
    version = SemVer(major=1, local="local")
    version.bump()
    check_version(version, 1, 0, 1, None, "local")
示例#4
0
def test_bump_no_args_retains_pre():
    version = SemVer(major=1, pre="pre")
    version.bump()
    check_version(version, 1, 0, 1, "pre", None)
示例#5
0
def test_bump_local():
    version = SemVer(major=1, minor=2, patch=3)
    version.bump(local="local")
    check_version(version, 1, 2, 3, None, "local")
示例#6
0
def test_bump_pre():
    version = SemVer(major=1, minor=2, patch=3)
    version.bump(pre="pre")
    check_version(version, 1, 2, 3, "pre", None)
示例#7
0
def test_bump_patch():
    version = SemVer(major=1, minor=2, patch=3)
    version.bump(patch=True)
    check_version(version, 1, 2, 4, None, None)
示例#8
0
def test_bump_minor():
    version = SemVer(major=1, minor=2, patch=3)
    version.bump(minor=True)
    check_version(version, 1, 3, 3, None, None)
示例#9
0
def test_str(version, expected):
    assert str(SemVer.parse(version)) == expected
示例#10
0
def test_parse(version, args):
    check_version(SemVer.parse(version), *args)
示例#11
0
def test_bump_minor_with_reset():
    version = SemVer(major=1, minor=2, patch=3)
    version.bump(minor=True, reset=True)
    check_version(version, 1, 3, 0, None, None)
示例#12
0
    def test_bump(self):
        version = SemVer(major=1, minor=2, patch=3)
        version.bump(major=True)
        self.check_version(version, 2, 2, 3, None, None)

        version = SemVer(major=1, minor=2, patch=3)
        version.bump(minor=True)
        self.check_version(version, 1, 3, 3, None, None)

        version = SemVer(major=1, minor=2, patch=3)
        version.bump(patch=True)
        self.check_version(version, 1, 2, 4, None, None)

        version = SemVer(major=1, minor=2, patch=3)
        version.bump(pre='pre')
        self.check_version(version, 1, 2, 3, 'pre', None)

        version = SemVer(major=1, minor=2, patch=3)
        version.bump(local='local')
        self.check_version(version, 1, 2, 3, None, 'local')

        version = SemVer(major=1, pre='pre')
        version.bump()
        self.check_version(version, 1, 0, 1, 'pre', None)

        version = SemVer(major=1, local='local')
        version.bump()
        self.check_version(version, 1, 0, 1, None, 'local')