def test_gdalversion_class_from_string(): v = GDALVersion.from_string('1.9.0') assert v.major == 1 and v.minor == 9 v = GDALVersion.from_string('1.9') assert v.major == 1 and v.minor == 9 v = GDALVersion.from_string('1.9a') assert v.major == 1 and v.minor == 9
def test_gdalversion_class_cmp(): assert GDALVersion(1, 0) == GDALVersion(1, 0) assert GDALVersion(2, 0) > GDALVersion(1, 0) assert GDALVersion(1, 1) > GDALVersion(1, 0) assert GDALVersion(1, 2) < GDALVersion(2, 2) # Because we don't care about patch component assert GDALVersion.from_string('1.0') == GDALVersion.from_string('1.0.10') assert GDALVersion.from_string('1.9') < GDALVersion.from_string('2.2.0') assert GDALVersion.from_string('2.0.0') > GDALVersion(1, 9)
def test_gdalversion_class_from_string_err(): invalids = ('foo', 'foo.bar', '1', '1.', '1.a', '.1') for invalid in invalids: with pytest.raises(ValueError): GDALVersion.from_string(invalid)