def create_version_info_from_str(): v = VersionInfo.from_str("1.2.3") assert v.major == 1 assert v.minor == 2 assert v.micro == 3 assert v.releaselevel == "final" assert v.serial == 0 v = VersionInfo.from_str("1.2.3a4") assert v.major == 1 assert v.minor == 2 assert v.micro == 3 assert v.releaselevel == "alpha" assert v.serial == 4 v = VersionInfo.from_str("1.2.3beta4") assert v.major == 1 assert v.minor == 2 assert v.micro == 3 assert v.releaselevel == "beta" assert v.serial == 4 v = VersionInfo.from_str("12.34.56rc789") assert v.major == 12 assert v.minor == 34 assert v.micro == 56 assert v.releaselevel == "candidate" assert v.serial == 789
def serialize_as_str(): v = VersionInfo(1, 2, 3, "final", 0) assert str(v) == "1.2.3" v = VersionInfo(1, 2, 3, "alpha", 4) assert str(v) == "1.2.3a4" v = VersionInfo(1, 2, 3, "candidate", 4) assert str(v) == "1.2.3rc4"
def create_version_info_from_fields(): v = VersionInfo(1, 2, 3, "alpha", 4) assert v.major == 1 assert v.minor == 2 assert v.micro == 3 assert v.releaselevel == "alpha" assert v.serial == 4