def test_complexImage(): """test an image.""" dut.load(f"{THISDIR}/testComplexImage.xcf") dut.image.save(f"{THISDIR}/testComplexImage.png") assert imgcompare.is_equal(dut.image, f"{THISDIR}/testComplexImage_expected.png", tolerance=0.2)
def test_oneLayerWithTransparency(): """test an image.""" dut.load(f"{THISDIR}/testOneLayerWithTransparency.xcf") dut.image.save(f"{THISDIR}/testOneLayerWithTransparency.png") assert imgcompare.is_equal( dut.image, f"{THISDIR}/testOneLayerWithTransparency_expected.png", tolerance=0.2)
def test_multipleOffsetMaskedGroups(): """Test multiple offset layer groups with masks.""" dut.load(f"{THISDIR}/multiple-offset-masked-groups.xcf") result = dut.image assert imgcompare.is_equal( result, f"{THISDIR}/multiple-offset-masked-groups.tga", tolerance=0.2, )
def test_singleMaskedGroup(): """Test a single group with layer mask.""" dut.load(f"{THISDIR}/single-masked-group.xcf") result = dut.image assert imgcompare.is_equal( result, f"{THISDIR}/single-masked-group.tga", tolerance=0.2, )
def test_DiagonalStar(): """Test diagonal star.""" dut.load(f"{THISDIR}/Diagonal-Star-17.vbr") assert imgcompare.is_equal(dut.image, f"{THISDIR}/desiredOutput_Diagonal-Star-17.png", tolerance=0.2) # test round-trip compatibility dut.save(f"{THISDIR}/actualOutput_Diagonal-Star-17.vbr") original = GimpVbrBrush(f"{THISDIR}/Diagonal-Star-17.vbr") assert dut == original
def test_foreground_png(): """test_foreground_png""" src = Image.open(f"{THISDIR}/data/foreground.png") dst = src.copy() dst = upscale_image(args, dst, models["scale"]) # dst.convert(src.mode).save(f"{THISDIR}/data/foreground_upresnet10_expected.png") assert imgcompare.is_equal( dst, f"{THISDIR}/data/foreground_upresnet10_expected.png", tolerance=0.2, )
def test_background_png(): """test_background_png""" src = Image.open(f"{THISDIR}/data/background.png") dst = src.copy() dst = denoise_image(args, dst, models["noise"]) # dst.convert(src.mode).save(f"{THISDIR}/data/background_noise_expected.png") assert imgcompare.is_equal( dst, f"{THISDIR}/data/background_noise_expected.png", tolerance=0.2, )
def test_feltpen(): """test felt pen.""" dut.load(f"{THISDIR}/feltpen.gih") # test image saving (explicit) dut.image.save(f"{THISDIR}/actualOutput_feltpen.png") # test for image match assert imgcompare.is_equal(dut.image, f"{THISDIR}/desiredOutput_feltpen.png", tolerance=0.2) os.remove(f"{THISDIR}/actualOutput_feltpen.png") # test round-trip compatibility dut.save(f"{THISDIR}/actualOutput_feltpen.gih") original = open(f"{THISDIR}/feltpen.gih", "rb").read() actual = open(f"{THISDIR}/actualOutput_feltpen.gih", "rb").read() assert actual == original os.remove(f"{THISDIR}/actualOutput_feltpen.gih")
def test_leopard(): dut.load(f"{THISDIR}/leopard.pat") # test image saving (explicit) dut.image.save(f"{THISDIR}/actualOutput_leopard.png") # test for image match assert imgcompare.is_equal(dut.image, f"{THISDIR}/desiredOutput_leopard.png", tolerance=0.2) os.remove(f"{THISDIR}/actualOutput_leopard.png") # test round-trip compatibility dut.save(f"{THISDIR}/actualOutput_leopard.pat") original = open(f"{THISDIR}/leopard.pat", "rb") actual = open(f"{THISDIR}/actualOutput_leopard.pat", "rb") assert actual.read() == original.read() original.close() actual.close() os.remove(f"{THISDIR}/actualOutput_leopard.pat")
def test_dunes(): """test dunes""" dut.load(f"{THISDIR}/dunes.gbr") # test image saving (explicit) dut.image.save(f"{THISDIR}/actualOutput_dunes.png") # test for image match assert imgcompare.is_equal(dut.image, f"{THISDIR}/desiredOutput_dunes.png", tolerance=0.2) os.remove(f"{THISDIR}/actualOutput_dunes.png") # test round-trip compatibility dut.save(f"{THISDIR}/actualOutput_dunes.gbr") original = open(f"{THISDIR}/dunes.gbr", "rb") actual = open(f"{THISDIR}/actualOutput_dunes.gbr", "rb") assert actual.read() == original.read().replace(b"\r\n", b"\n") original.close() actual.close() os.remove(f"{THISDIR}/actualOutput_dunes.gbr")