예제 #1
0
def test_header_from_to(fixture):
    header = FileHeader.frombytes(fixture)
    assert header.tobytes() == fixture
예제 #2
0
def test_header_exception(fixture):
    with pytest.raises(ValueError):
        FileHeader.frombytes(b' ' + fixture)
예제 #3
0
from psd_tools.psd.image_data import ImageData

from ..utils import check_write_read

RAW_IMAGE_3x3_8bit = b'\x00\x01\x02\x01\x01\x01\x01\x00\x00'
RAW_IMAGE_2x2_16bit = b'\x00\x01\x00\x02\x00\x03\x00\x04'


def test_image_data():
    check_write_read(ImageData())
    check_write_read(ImageData(data=b'\x00'))


@pytest.mark.parametrize('compression, data, header', [
    (Compression.RAW, [RAW_IMAGE_3x3_8bit] * 3,
     FileHeader(width=3, height=3, depth=8, channels=3, version=1)),
    (Compression.PACK_BITS, [RAW_IMAGE_3x3_8bit] * 3,
     FileHeader(width=3, height=3, depth=8, channels=3, version=1)),
    (Compression.ZIP, [RAW_IMAGE_3x3_8bit] * 3,
     FileHeader(width=3, height=3, depth=8, channels=3, version=1)),
    (Compression.RAW, [RAW_IMAGE_3x3_8bit] * 3,
     FileHeader(width=3, height=3, depth=8, channels=3, version=2)),
    (Compression.PACK_BITS, [RAW_IMAGE_3x3_8bit] * 3,
     FileHeader(width=3, height=3, depth=8, channels=3, version=2)),
    (Compression.ZIP, [RAW_IMAGE_3x3_8bit] * 3,
     FileHeader(width=3, height=3, depth=8, channels=3, version=2)),
    (Compression.RAW, [RAW_IMAGE_2x2_16bit] * 3,
     FileHeader(width=2, height=2, depth=16, channels=3, version=1)),
    (Compression.PACK_BITS, [RAW_IMAGE_2x2_16bit] * 3,
     FileHeader(width=2, height=2, depth=16, channels=3, version=1)),
    (Compression.ZIP, [RAW_IMAGE_2x2_16bit] * 3,