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'
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')
def test_bump_no_args_retains_local(): version = SemVer(major=1, local="local") version.bump() check_version(version, 1, 0, 1, None, "local")
def test_bump_no_args_retains_pre(): version = SemVer(major=1, pre="pre") version.bump() check_version(version, 1, 0, 1, "pre", None)
def test_bump_local(): version = SemVer(major=1, minor=2, patch=3) version.bump(local="local") check_version(version, 1, 2, 3, None, "local")
def test_bump_pre(): version = SemVer(major=1, minor=2, patch=3) version.bump(pre="pre") check_version(version, 1, 2, 3, "pre", None)
def test_bump_patch(): version = SemVer(major=1, minor=2, patch=3) version.bump(patch=True) check_version(version, 1, 2, 4, None, None)
def test_bump_minor(): version = SemVer(major=1, minor=2, patch=3) version.bump(minor=True) check_version(version, 1, 3, 3, None, None)
def test_str(version, expected): assert str(SemVer.parse(version)) == expected
def test_parse(version, args): check_version(SemVer.parse(version), *args)
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)
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')