Ejemplo n.º 1
0
def test_bump_by_error(by):
    v = Version(release=1)

    with pytest.raises(TypeError):
        v.bump_epoch(by=by)

    with pytest.raises(TypeError):
        v.bump_dev(by=by)

    with pytest.raises(TypeError):
        v.bump_pre('a', by=by)

    with pytest.raises(TypeError):
        v.bump_post(by=by)
Ejemplo n.º 2
0
def test_bump_by_value_error():
    v = Version(release=1)

    with pytest.raises(ValueError, match='negative'):
        v.bump_epoch(by=-1)

    with pytest.raises(ValueError, match='negative'):
        v.bump_dev(by=-1)

    with pytest.raises(ValueError, match='negative'):
        v.bump_pre(by=-1)

    with pytest.raises(ValueError, match='negative'):
        v.bump_post(by=-1)
Ejemplo n.º 3
0
def bump_version(version: parver.Version, args) -> parver.Version:
    if args.release:
        return version.base_version()

    if args.dev:
        if args.to is not None:
            return version.replace(dev=args.to)
        else:
            return version.bump_dev()

    version = version.replace(dev=None)

    if args.post:
        if args.to is not None:
            return version.replace(post=args.to)
        else:
            return version.bump_post()

    if args.rc:
        if version.is_postrelease:
            version = version.replace(post=None)

        if args.to is not None:
            return version.replace(pre_tag="rc", pre=args.to)
        else:
            return version.bump_pre("rc")