コード例 #1
0
def test_differ_assert_passes():
    image1 = LivePillowImage(Image.new('RGBA', (10, 20)))
    image2 = LivePillowImage(Image.new('RGBA', (10, 20)))

    differ = LiveImageDiffer()

    differ.assert_equal(image1, image2)
コード例 #2
0
def test_differ_assert_fails():
    blue = (0, 0, 255, 255)

    image1 = LivePillowImage(Image.new('RGBA', (10, 20)))
    image1.set_pixel((5, 10), blue)
    image2 = LivePillowImage(Image.new('RGBA', (10, 20)))

    differ = LiveImageDiffer()

    with pytest.raises(AssertionError, match=r'Images differ by 1 pixel.'):
        differ.assert_equal(image1, image2)
コード例 #3
0
def test_live_png_as_painter(tmp_path):
    blue = (0, 0, 255, 255)
    white = (255, 255, 255, 255)

    image1 = LivePillowImage(Image.new('RGBA', (10, 20)))
    image1.set_pixel((5, 10), blue)
    image1.set_pixel((6, 10), white)

    image2 = LivePillowImage(Image.new('RGBA', (10, 20)))
    image2.set_pixel((5, 10), blue)
    bytes2 = image2.convert_to_png()
    image3 = LivePng(bytes2)
    painter3 = image3.convert_to_painter()
    painter3.set_pixel((6, 10), white)

    differ = LiveImageDiffer(tmp_path)

    differ.assert_equal(image1, painter3, 'live_png_as_painter')