def test_unsupported_codec(): # Arrange codec = "unsupported_codec" # Act / Assert with pytest.raises(ValueError): features.check_codec(codec) with pytest.raises(ValueError): features.version_codec(codec)
def test_sanity(self): # internal version number assert re.search(r"\d+\.\d+$", features.version_codec("jpg")) with Image.open(TEST_FILE) as im: im.load() assert im.mode == "RGB" assert im.size == (128, 128) assert im.format == "JPEG" assert im.get_format_mimetype() == "image/jpeg"
def test_sanity(): # Internal version number assert re.search(r"\d+\.\d+\.\d+$", features.version_codec("jpg_2000")) with Image.open("Tests/images/test-card-lossless.jp2") as im: px = im.load() assert px[0, 0] == (0, 0, 0) assert im.mode == "RGB" assert im.size == (640, 480) assert im.format == "JPEG2000" assert im.get_format_mimetype() == "image/jp2"
def test_sanity(self, tmp_path): # internal version number assert re.search(r"\d+\.\d+\.\d+(\.\d+)?$", features.version_codec("zlib")) test_file = str(tmp_path / "temp.png") hopper("RGB").save(test_file) with Image.open(test_file) as im: im.load() assert im.mode == "RGB" assert im.size == (128, 128) assert im.format == "PNG" assert im.get_format_mimetype() == "image/png" for mode in ["1", "L", "P", "RGB", "I", "I;16"]: im = hopper(mode) im.save(test_file) with Image.open(test_file) as reloaded: if mode == "I;16": reloaded = reloaded.convert(mode) assert_image_equal(reloaded, im)
def test_version(self): assert re.search(r"\d+\.\d+\.\d+$", features.version_codec("libtiff"))