Esempio n. 1
0
 def test_truncated(self):
     b = BytesIO(
         b"BM000000000000"  # head_data
         + _binary.o32le(
             ImageFile.SAFEBLOCK + 1 + 4
         )  # header_size, so BmpImagePlugin will try to read SAFEBLOCK + 1 bytes
         + (b"0" * ImageFile.SAFEBLOCK
            )  # only SAFEBLOCK bytes, so that the header is truncated
     )
     with pytest.raises(OSError) as e:
         BmpImagePlugin.BmpImageFile(b)
     assert str(e.value) == "Truncated File Read"
Esempio n. 2
0
    def test_little_endian(self):
        self.assertEqual(_binary.i16le(b'\xff\xff\x00\x00'), 65535)
        self.assertEqual(_binary.i32le(b'\xff\xff\x00\x00'), 65535)

        self.assertEqual(_binary.o16le(65535), b'\xff\xff')
        self.assertEqual(_binary.o32le(65535), b'\xff\xff\x00\x00')
Esempio n. 3
0
    def test_little_endian(self):
        self.assertEqual(_binary.i16le(b"\xff\xff\x00\x00"), 65535)
        self.assertEqual(_binary.i32le(b"\xff\xff\x00\x00"), 65535)

        self.assertEqual(_binary.o16le(65535), b"\xff\xff")
        self.assertEqual(_binary.o32le(65535), b"\xff\xff\x00\x00")
Esempio n. 4
0
def test_little_endian():
    assert _binary.i16le(b"\xff\xff\x00\x00") == 65535
    assert _binary.i32le(b"\xff\xff\x00\x00") == 65535

    assert _binary.o16le(65535) == b"\xff\xff"
    assert _binary.o32le(65535) == b"\xff\xff\x00\x00"