This file is indexed.

/usr/lib/python2.7/dist-packages/cairocffi/test_pixbuf.py is in python-cairocffi 0.5.4-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# coding: utf8
"""
    cairocffi.test_pixbuf
    ~~~~~~~~~~~~~~~~~~~~~

    Test suite for cairocffi.pixbuf.

    :copyright: Copyright 2013 by Simon Sapin
    :license: BSD, see LICENSE for details.

"""

import base64
import zlib

import pytest

from . import pixbuf, constants
from .compat import pixel


PNG_BYTES = base64.b64decode(
    b'iVBORw0KGgoAAAANSUhEUgAAAAMAAAACCAYAAACddGYaAAAAE0lEQV'
    b'QI12NkaPjfwAAFTAxIAAAuNwIDqJbDRgAAAABJRU5ErkJggg==')

JPEG_BYTES = zlib.decompress(base64.b64decode(
    b'eJylzb0JgFAMBOA704hYvIC9oygIou7nPFq4g3+Nm0RT+iy9VPkIF9vsQhjavgVJdM/ATjS'
    b'+/YqX/O2gzdAUCUSoSJSitAUFiHdS1xArXBlr5qrf2wO58HkiigrlWK+T7TezChqU'))


def test_api():
    with pytest.raises(pixbuf.ImageLoadingError):
        pixbuf.decode_to_image_surface(b'')
    with pytest.raises(pixbuf.ImageLoadingError):
        pixbuf.decode_to_image_surface(b'Not a valid image.')
    with pytest.raises(pixbuf.ImageLoadingError):
        pixbuf.decode_to_image_surface(PNG_BYTES[:10])
    surface, format_name = pixbuf.decode_to_image_surface(PNG_BYTES)
    assert format_name == 'png'
    assert_decoded(surface)


def test_gdk():
    if pixbuf.gdk is None:
        pytest.xfail()
    pixbuf_obj, format_name = pixbuf.decode_to_pixbuf(PNG_BYTES)
    assert format_name == 'png'
    assert_decoded(pixbuf.pixbuf_to_cairo_gdk(pixbuf_obj))


def test_slices():
    pixbuf_obj, format_name = pixbuf.decode_to_pixbuf(PNG_BYTES)
    assert format_name == 'png'
    assert_decoded(pixbuf.pixbuf_to_cairo_png(pixbuf_obj))


def test_png():
    pixbuf_obj, format_name = pixbuf.decode_to_pixbuf(JPEG_BYTES)
    assert format_name == 'jpeg'
    assert_decoded(pixbuf.pixbuf_to_cairo_slices(pixbuf_obj),
                   constants.FORMAT_RGB24, b'\xff\x00\x80\xff')


def assert_decoded(surface, format_=constants.FORMAT_ARGB32,
                   rgba=b'\x80\x00\x40\x80'):
    assert surface.get_width() == 3
    assert surface.get_height() == 2
    assert surface.get_format() == format_
    assert surface.get_data()[:] == pixel(rgba) * 6