def test_std_repr(self): """ test repr usage for StandardVersion """ assert repr(StandardVersion.parse('1.2.3-YOKO')) == "StandardVersion(1, 2, 3, 'YOKO')" assert repr(StandardVersion.parse('1.2.3')) == "StandardVersion(1, 2, 3, None)" assert repr(StandardVersion.parse('1.2')) == "StandardVersion(1, 2, 0, None)" assert repr(StandardVersion.parse('1')) == "StandardVersion(1, 0, 0, None)"
def test_std_string(self): """ test string usage for StandardVersion """ assert str(StandardVersion.parse('1.2.3-YOKO')) == '1.2.3-YOKO' assert str(StandardVersion.parse('1.2.3')) == '1.2.3' assert str(StandardVersion.parse('1.2')) == '1.2' assert str(StandardVersion.parse('1')) == '1.0'
def test_std_equals(self): """ test equals override for StandardVersion """ version1 = StandardVersion.parse('1.2.3-YOKO') version2 = StandardVersion.parse('1.2.3-YOKO') assert version1 is not version2, 'Two instances of StandardVersion are not the same' assert version1 == version2
def test_std_set(self): """ test set usage for StandardVersion """ test = set() test.add(StandardVersion.parse('1.2.3-YOKO')) test.add(StandardVersion.parse('1.2.3-YOKO')) assert len(test) == 1 assert StandardVersion.parse('1.2.3-YOKO') in test
def test_range_checking(self): """ test version range checking """ assert not VersionRange.parse('[1.0, 2.0)').contains(StandardVersion.parse('0.1')) assert VersionRange.parse('[1.0, 2.0)').contains(StandardVersion.parse('1')) assert VersionRange.parse('[1.0, 2.0)').contains(StandardVersion.parse('1.5')) assert not VersionRange.parse('[1.0, 2.0)').contains(StandardVersion.parse('2')) assert not VersionRange.parse('[1.0, 2.0)').contains(StandardVersion.parse('5')) assert not VersionRange.parse('(1.0, 2.0)').contains(StandardVersion.parse('0.1')) assert not VersionRange.parse('(1.0, 2.0]').contains(StandardVersion.parse('1')) assert VersionRange.parse('(1.0, 2.0]').contains(StandardVersion.parse('1.5')) assert VersionRange.parse('(1.0, 2.0]').contains(StandardVersion.parse('2')) assert not VersionRange.parse('(1.0, 2.0)').contains(StandardVersion.parse('5'))
def test_std_init(self): """ create StandardVersion from string """ version = StandardVersion.parse('1.2.3-YOKO') assert version.version[0] == 1 assert version.version[1] == 2 assert version.version[2] == 3 assert version.qualifier == 'YOKO' version = StandardVersion.parse('1.2.1102-RC2.4622') assert version.version[0] == 1 assert version.version[1] == 2 assert version.version[2] == 1102 assert version.qualifier == 'RC2.4622'
def test_std_cmp(self): """ test cmp usage for StandardVersion """ assert StandardVersion.parse('0') < StandardVersion.parse('1') assert StandardVersion.parse('2') < StandardVersion.parse('10') assert StandardVersion.parse('0.9') < StandardVersion.parse('1.0') assert StandardVersion.parse('0.0.9') < StandardVersion.parse('1.0.0') assert StandardVersion.parse('1.0.0-A') < StandardVersion.parse('1.0.0-B') assert StandardVersion.parse('1.0.0-A') < StandardVersion.parse('1.0.0'), 'Version with qualifier should be less than one without'
def test_std_hash(self): """ test hash override for StandardVersion """ assert hash(StandardVersion.parse('1.2.3-YOKO')) != 0, 'StdVersions have non-zero hashes' assert hash(StandardVersion.parse('1.2.3-YOKO')) == hash(StandardVersion.parse('1.2.3-YOKO'))
def test_std_not_equals(self): """ test not equals override for StandardVersion """ assert StandardVersion.parse('1.2.3-YOKO') != StandardVersion.parse('1.2.3-NOBU'), 'Two instances of StandardVersion are equal' assert not (StandardVersion.parse('1.2.3-YOKO') != StandardVersion.parse('1.2.3-YOKO')), 'Two instances of StandardVersion are equal'