Esempio n. 1
0
def test_no_metadata(caplog):
    caplog.set_level(logging.WARNING)

    with PngImageFile("src/tests/no_meta.png") as fp:
        decode(fp)

        assert (
            "Warning: Unable to fetch image metadata, using default value (Red).\n"
            in caplog.text)

        result = decode(fp, Color.orange)
        assert result == uid_18
Esempio n. 2
0
def test_custom_encode(colors):
    result, meta = encode(uid_18, "custom", colors[0], colors[1], colors[2])
    result.save("test.png", pnginfo=meta)

    with PngImageFile("test.png") as fp:
        assert decode(fp) == uid_18

    delete_test_png()
Esempio n. 3
0
    def _action(uid: str, color: Color = Color.red):
        result, meta = encode(uid)
        result.save("test.png", pnginfo=meta)

        with PngImageFile("test.png") as fp:
            uid_result = decode(fp)

        return result, uid_result
Esempio n. 4
0
def test_too_large():
    with pytest.raises(ValueError):
        with PngImageFile("src/tests/enlarged.png") as fp:
            decode(fp)
Esempio n. 5
0
def test_decode():
    with PngImageFile(f"src/tests/{uid_18}.png") as fp:
        result = decode(fp)

    assert result == uid_18