Giter VIP home page Giter VIP logo

Comments (19)

audriusk avatar audriusk commented on May 30, 2024

Yes, all the dependencies that can't be installed into virtualenv, are covered by Slackware packages. Here's the full list:

  • Python 2.6.6
  • Pango 1.28.4
  • Cairo 1.10.2
  • PyCairo 1.8.10
  • PyGTK 2.22.0
  • PyGObject 2.26.0
  • ImageMagick 6.6.6_10

Other dependencies were installed inside virtualenv.

The tests do run without WEASYPRINT_USE_PYGTK, it's just that one additional test fails, the one that tries to import from gi.repository, even though PyGObject 3.x is not present on the system. Here are the tracebacks:

==================================== test session starts ====================================
platform linux2 -- Python 2.6.6 -- pytest-2.2.4
collected 126 items 

tests/test_api.py F..FF..
tests/test_boxes.py ....................
tests/test_css.py ...........
tests/test_css_validation.py ............
tests/test_draw.py ....x.x..........x
tests/test_layout.py .............................................
tests/test_pdf.py .....
tests/test_stacking.py ..
tests/test_text.py .F....

========================================= FAILURES ==========================================
__________________________________ test_unicode_filenames ___________________________________
Traceback (most recent call last):
  File "/root/venv/lib/python2.6/site-packages/weasyprint/tests/testing_utils.py", line 99, in wrapper
    function()
  File "/root/venv/lib/python2.6/site-packages/weasyprint/tests/test_api.py", line 386, in test_unicode_filenames
    assert read_file(unicode_filename) == png_bytes
  File "/usr/lib64/python2.6/contextlib.py", line 34, in __exit__
    self.gen.throw(type, value, traceback)
  File "/root/venv/lib/python2.6/site-packages/weasyprint/tests/test_api.py", line 44, in chdir
    yield
  File "/root/venv/lib/python2.6/site-packages/weasyprint/tests/test_api.py", line 376, in test_unicode_filenames
    TestHTML(string=html).write_png(unicode_filename)
  File "/root/venv/lib/python2.6/site-packages/weasyprint/__init__.py", line 167, in write_png
    return document.write_png(target, resolution)
  File "/root/venv/lib/python2.6/site-packages/weasyprint/document.py", line 136, in write_png
    surface.write_to_png(target)
TypeError: Surface.write_to_png takes one argument which must be a filename (str), file object, or a file-like object which has a "write" method (like StringIO)
____________________________________ test_python_render _____________________________________
Traceback (most recent call last):
  File "/root/venv/lib/python2.6/site-packages/weasyprint/tests/testing_utils.py", line 99, in wrapper
    function()
  File "/root/venv/lib/python2.6/site-packages/weasyprint/tests/test_api.py", line 257, in test_python_render
    assert read_file(pdf_filename) == pdf_bytes
  File "/usr/lib64/python2.6/contextlib.py", line 34, in __exit__
    self.gen.throw(type, value, traceback)
  File "/root/venv/lib/python2.6/site-packages/weasyprint/tests/test_api.py", line 58, in temp_directory
    yield directory
  File "/root/venv/lib/python2.6/site-packages/weasyprint/tests/test_api.py", line 245, in test_python_render
    html.write_png(png_filename, stylesheets=[css])
  File "/root/venv/lib/python2.6/site-packages/weasyprint/__init__.py", line 167, in write_png
    return document.write_png(target, resolution)
  File "/root/venv/lib/python2.6/site-packages/weasyprint/document.py", line 136, in write_png
    surface.write_to_png(target)
TypeError: Surface.write_to_png takes one argument which must be a filename (str), file object, or a file-like object which has a "write" method (like StringIO)
_________________________________ test_command_line_render __________________________________
Traceback (most recent call last):
  File "/root/venv/lib/python2.6/site-packages/weasyprint/tests/testing_utils.py", line 99, in wrapper
    function()
  File "/root/venv/lib/python2.6/site-packages/weasyprint/tests/test_api.py", line 344, in test_command_line_render
    assert stdout == png_bytes
  File "/usr/lib64/python2.6/contextlib.py", line 34, in __exit__
    self.gen.throw(type, value, traceback)
  File "/root/venv/lib/python2.6/site-packages/weasyprint/tests/test_api.py", line 44, in chdir
    yield
  File "/root/venv/lib/python2.6/site-packages/weasyprint/tests/test_api.py", line 307, in test_command_line_render
    run('combined.html out1.png')
  File "/root/venv/lib/python2.6/site-packages/weasyprint/tests/test_api.py", line 291, in run
    __main__.main(args.split(), stdin=stdin, stdout=stdout)
  File "/root/venv/lib/python2.6/site-packages/weasyprint/__main__.py", line 79, in main
    getattr(html, 'write_' + format_)(output, stylesheets=args.stylesheet)
  File "/root/venv/lib/python2.6/site-packages/weasyprint/__init__.py", line 167, in write_png
    return document.write_png(target, resolution)
  File "/root/venv/lib/python2.6/site-packages/weasyprint/document.py", line 136, in write_png
    surface.write_to_png(target)
TypeError: Surface.write_to_png takes one argument which must be a filename (str), file object, or a file-like object which has a "write" method (like StringIO)
________________________________________ test_pygtk _________________________________________
Traceback (most recent call last):
  File "/root/venv/lib/python2.6/site-packages/weasyprint/tests/testing_utils.py", line 99, in wrapper
    function()
  File "/root/venv/lib/python2.6/site-packages/weasyprint/tests/test_text.py", line 105, in test_pygtk
    from gi.repository import Pango
ImportError: No module named gi.repository
===================== 4 failed, 119 passed, 3 xfailed in 18.13 seconds ======================

from weasyprint.

SimonSapin avatar SimonSapin commented on May 30, 2024

Should be fixed in 9447363. It turns out that only py2cairo >= 1.10 supports Unicode filenames, but for some reason the test still passed with 1.8.8. (You have 1.8.10 where they explicitly disallowed it. 1.8.8 segfaults, but only sometimes…)

Anyway, could you run the test suite again against master? Thanks for the testing!

from weasyprint.

audriusk avatar audriusk commented on May 30, 2024

With master I am getting 122 passed, 3 xfailed in 16.67 seconds, thanks!

Out of curiosity I ran the test suite against master on recently announced Slackware 14 beta with my PyGObject 3.0.4 package installed and got 6 failed tests (different than the ones that were failing on Slackware 13.37). Should I open a new issue or report it here?

from weasyprint.

SimonSapin avatar SimonSapin commented on May 30, 2024

Le 28/07/2012 17:39, Audrius Kažukauskas a écrit :

With master I am getting 122 passed, 3 xfailed in 16.67 seconds, thanks!

Great!

Out of curiosity I ran the test suite against master on recently
announced Slackware 14 beta with my PyGObject 3.0.4 package installed
and got 6 failed tests (different than the ones that were failing on
Slackware 13.37). Should I open a new issue or report it here?

Here is fine.

Simon

from weasyprint.

audriusk avatar audriusk commented on May 30, 2024

OK, first the list of dependencies provided by system packages (others inside virtualenv):

  • Python 2.7.3
  • Pango 1.30.1
  • Cairo 1.10.2
  • gobject-introspection 1.32.1
  • PyCairo 1.8.10
  • PyGTK 2.24.0
  • PyGObject 2.28.6 and 3.0.4
  • ImageMagick 6.7.7_10

And the tracebacks:

==================================== test session starts ====================================
platform linux2 -- Python 2.7.3 -- pytest-2.2.4
collected 125 items 

weasyprint/tests/test_api.py .......
weasyprint/tests/test_boxes.py ....................
weasyprint/tests/test_css.py ...........
weasyprint/tests/test_css_validation.py ............
weasyprint/tests/test_draw.py F.F.x.x....F.....x
weasyprint/tests/test_layout.py ........F....................................
weasyprint/tests/test_pdf.py .....
weasyprint/tests/test_stacking.py ..
weasyprint/tests/test_text.py F..F.

========================================= FAILURES ==========================================
_______________________________________ test_opacity ________________________________________
Traceback (most recent call last):
  File "/home/audrius/src/WeasyPrint/weasyprint/tests/testing_utils.py", line 99, in wrapper
    function()
  File "/home/audrius/src/WeasyPrint/weasyprint/tests/test_draw.py", line 1812, in test_opacity
    '''),
  File "/home/audrius/src/WeasyPrint/weasyprint/tests/test_draw.py", line 84, in assert_same_rendering
    reference, lines)
  File "/home/audrius/src/WeasyPrint/weasyprint/tests/test_draw.py", line 175, in assert_pixels_equal
    % (x, y, name, expected_pixel, pixel))
AssertionError: Pixel (2, 22) in opacity_color: expected rgba(255, 255, 175, 175), got rgab(245, 255, 218, 175)
_____________________________________ test_before_after _____________________________________
Traceback (most recent call last):
  File "/home/audrius/src/WeasyPrint/weasyprint/tests/testing_utils.py", line 99, in wrapper
    function()
  File "/home/audrius/src/WeasyPrint/weasyprint/tests/test_draw.py", line 1459, in test_before_after
    ''')
  File "/home/audrius/src/WeasyPrint/weasyprint/tests/test_draw.py", line 84, in assert_same_rendering
    reference, lines)
  File "/home/audrius/src/WeasyPrint/weasyprint/tests/test_draw.py", line 175, in assert_pixels_equal
    % (x, y, name, expected_pixel, pixel))
AssertionError: Pixel (14, 62) in pseudo_before_reference: expected rgba(189, 255, 190, 135), got rgab(192, 255, 193, 135)
________________________________________ test_images ________________________________________
Traceback (most recent call last):
  File "/home/audrius/src/WeasyPrint/weasyprint/tests/testing_utils.py", line 99, in wrapper
    function()
  File "/home/audrius/src/WeasyPrint/weasyprint/tests/test_draw.py", line 978, in test_images
    ''' % filename)
  File "/home/audrius/src/WeasyPrint/weasyprint/tests/test_draw.py", line 64, in assert_pixels
    expected_raw)
  File "/home/audrius/src/WeasyPrint/weasyprint/tests/test_draw.py", line 175, in assert_pixels_equal
    % (x, y, name, expected_pixel, pixel))
AssertionError: Pixel (2, 2) in inline_image_pattern.svg: expected rgba(0, 0, 255, 0), got rgab(255, 255, 255, 255)
-------------------------------------- Captured stderr --------------------------------------
1 errors logged:
WARNING: Error for image at file:///home/audrius/src/WeasyPrint/weasyprint/tests/resources/pattern.svg : TinyException("NoDecodeDelegateForThisImageFormat `' @ error/blob.c/BlobToImage/348",)
________________________________________ test_images ________________________________________
Traceback (most recent call last):
  File "/home/audrius/src/WeasyPrint/weasyprint/tests/testing_utils.py", line 99, in wrapper
    function()
  File "/home/audrius/src/WeasyPrint/weasyprint/tests/test_layout.py", line 2155, in test_images
    body, img = get_img(html)
  File "/home/audrius/src/WeasyPrint/weasyprint/tests/test_layout.py", line 2133, in get_img
    line, = body.children
ValueError: need more than 0 values to unpack
-------------------------------------- Captured stderr --------------------------------------
1 errors logged:
WARNING: Error for image at file:///home/audrius/src/WeasyPrint/weasyprint/tests/resources/pattern.svg : TinyException("NoDecodeDelegateForThisImageFormat `' @ error/blob.c/BlobToImage/348",)
_____________________________________ test_line_content _____________________________________
Traceback (most recent call last):
  File "/home/audrius/src/WeasyPrint/weasyprint/tests/testing_utils.py", line 99, in wrapper
    function()
  File "/home/audrius/src/WeasyPrint/weasyprint/tests/test_text.py", line 42, in test_line_content
    assert text[resume_at:] == remaining
AssertionError: assert u'for test' == u'text for test'
  - for test
  + text for test
  ? +++++
____________________________________ test_line_breaking _____________________________________
Traceback (most recent call last):
  File "/home/audrius/src/WeasyPrint/weasyprint/tests/testing_utils.py", line 99, in wrapper
    function()
  File "/home/audrius/src/WeasyPrint/weasyprint/tests/test_text.py", line 68, in test_line_breaking
    assert string[resume_at:] == 'text for test'
AssertionError: assert u'for test' == u'text for test'
  - for test
  + text for test
  ? +++++
===================== 6 failed, 116 passed, 3 xfailed in 16.28 seconds ======================

from weasyprint.

SimonSapin avatar SimonSapin commented on May 30, 2024

Ok, in order:

When the error message talks about pixels and rgba, there should be PNG images in weasyprint/tests/test_results. Please upload them somewhere or send them by email.

Apparently pattern.svg is treated as a raster image. What output do you have for this?

import mimetypes
mimetypes.guess_type('pattern.svg')

It should be ('image/svg+xml', None). If it is not, try adding mimetypes.add_type('image/svg+xml', '.svg') in images.py (or anywhere) at the module level.

The remaining failing tests rely on some fonts being installed, but I’m not sure which ones. Some day we’ll rewrite them with Ahem, don’t bother too much.

from weasyprint.

audriusk avatar audriusk commented on May 30, 2024

Sent images by email.

>>> import mimetypes
>>> mimetypes.guess_type('pattern.svg')
(None, None)

Looking into mimetypes.py reveals that it uses Apache type list to figure out unknown MIME types, which explains why it doesn't work for me, since I do not have Apache installed. Adding mimetypes.add_type('image/svg+xml', '.svg') in images.py reduces failed test number to 4 (the ones about pixels).

from weasyprint.

SimonSapin avatar SimonSapin commented on May 30, 2024

I pushed a few more changes to master, unfortunately more in the tests themselves than in the code. Hopefully they should fix all the failures above.

In case you feel like doing yet more testing I also pushed a 'pixbuf' branch :) It uses gdk-pixbuf2 instead of Pystacia/ImageMagick to load raster images. It’s generally not a problem on linux but Pystacia can by tricky to install, while pixbuf is already in PyGTK. I’d look up the name of the Slackware packages, but http://packages.slackware.it/ is down :/

Once again, there are different code paths for PyGTK and PyGObject-introspection.

from weasyprint.

SimonSapin avatar SimonSapin commented on May 30, 2024

About the test failures with text: your PNG output has no text hinting for some reason. For another unknown reason, the two runs of texts that are supposed to be the same are drawn at a slightly different position (well blow 1px of difference). I added a tolerance on the RGB value of each pixel.

from weasyprint.

audriusk avatar audriusk commented on May 30, 2024

I just realized that I have freetype patched with Infinality font rendering patches (this is on Slackware 14 beta which I am using on my laptop). That could be the reason why rendered text is different from what's expected.

Now the test results on master branch. On Slackware 13.37:

==================================== test session starts ====================================
platform linux2 -- Python 2.6.6 -- pytest-2.2.4
collected 125 items 

tests/test_api.py ....F..
tests/test_boxes.py ....................
tests/test_css.py ...........
tests/test_css_validation.py ............
tests/test_draw.py .F..x.x....F.....x
tests/test_layout.py ........F....................................
tests/test_pdf.py .....
tests/test_stacking.py ..
tests/test_text.py .....

========================================= FAILURES ==========================================
_________________________________ test_command_line_render __________________________________
Traceback (most recent call last):
  File "/root/WeasyPrint/weasyprint/tests/testing_utils.py", line 99, in wrapper
    function()
  File "/root/WeasyPrint/weasyprint/tests/test_api.py", line 327, in test_command_line_render
    assert read_file('out6.png') == png_bytes
AssertionError: assert '\x89PNG\r\n\...END\xaeB`\x82' == '\x89PNG\r\n\x...END\xaeB`\x82'
  Detailed information too verbose, truncated
-------------------------------------- Captured stderr --------------------------------------
1 errors logged:
WARNING: Unsupported stylesheet type: text/plain
_______________________________________ test_unicode ________________________________________
Traceback (most recent call last):
  File "/root/WeasyPrint/weasyprint/tests/testing_utils.py", line 99, in wrapper
    function()
  File "/root/WeasyPrint/weasyprint/tests/test_draw.py", line 1643, in test_unicode
    lines = document_to_pixels(document, 'unicode', 200, 50)
  File "/root/WeasyPrint/weasyprint/tests/test_draw.py", line 142, in document_to_pixels
    return png_to_pixels(document.write_png(), expected_width, expected_height)
  File "/root/WeasyPrint/weasyprint/tests/test_draw.py", line 147, in png_to_pixels
    assert image.size == (expected_width, expected_height)
AssertionError: assert (794L, 1123L) == (200, 50)
  At index 0 diff: 794L != 200
-------------------------------------- Captured stderr --------------------------------------
1 errors logged:
WARNING: Unsupported stylesheet type: text/plain
________________________________________ test_images ________________________________________
Traceback (most recent call last):
  File "/root/WeasyPrint/weasyprint/tests/testing_utils.py", line 99, in wrapper
    function()
  File "/root/WeasyPrint/weasyprint/tests/test_draw.py", line 979, in test_images
    ''' % filename)
  File "/root/WeasyPrint/weasyprint/tests/test_draw.py", line 64, in assert_pixels
    expected_raw)
  File "/root/WeasyPrint/weasyprint/tests/test_draw.py", line 176, in assert_pixels_equal
    % (x, y, name, expected_pixel, pixel))
AssertionError: Pixel (2, 2) in inline_image_pattern.svg: expected rgba(0, 0, 255, 0), got rgab(255, 255, 255, 255)
-------------------------------------- Captured stderr --------------------------------------
1 errors logged:
WARNING: Error for image at file:///root/WeasyPrint/weasyprint/tests/resources/pattern.svg : TinyException("NoDecodeDelegateForThisImageFormat `' @ error/blob.c/BlobToImage/348",)
________________________________________ test_images ________________________________________
Traceback (most recent call last):
  File "/root/WeasyPrint/weasyprint/tests/testing_utils.py", line 99, in wrapper
    function()
  File "/root/WeasyPrint/weasyprint/tests/test_layout.py", line 2155, in test_images
    body, img = get_img(html)
  File "/root/WeasyPrint/weasyprint/tests/test_layout.py", line 2133, in get_img
    line, = body.children
ValueError: need more than 0 values to unpack
-------------------------------------- Captured stderr --------------------------------------
1 errors logged:
WARNING: Error for image at file:///root/WeasyPrint/weasyprint/tests/resources/pattern.svg : TinyException("NoDecodeDelegateForThisImageFormat `' @ error/blob.c/BlobToImage/348",)
===================== 4 failed, 118 passed, 3 xfailed in 13.25 seconds ======================

On Slackware 14 beta:

==================================== test session starts ====================================
platform linux2 -- Python 2.7.3 -- pytest-2.2.4
collected 125 items 

tests/test_api.py .......
tests/test_boxes.py ....................
tests/test_css.py ...........
tests/test_css_validation.py ............
tests/test_draw.py ..F.x.x..........x
tests/test_layout.py .............................................
tests/test_pdf.py .....
tests/test_stacking.py ..
tests/test_text.py .....

========================================= FAILURES ==========================================
_____________________________________ test_before_after _____________________________________
Traceback (most recent call last):
  File "/home/audrius/src/WeasyPrint/weasyprint/tests/testing_utils.py", line 99, in wrapper
    function()
  File "/home/audrius/src/WeasyPrint/weasyprint/tests/test_draw.py", line 1480, in test_before_after
    ], tolerance=10)
  File "/home/audrius/src/WeasyPrint/weasyprint/tests/test_draw.py", line 85, in assert_same_rendering
    reference, lines, tolerance)
  File "/home/audrius/src/WeasyPrint/weasyprint/tests/test_draw.py", line 176, in assert_pixels_equal
    % (x, y, name, expected_pixel, pixel))
AssertionError: Pixel (3, 194) in pseudo_quotes_reference: expected rgba(195, 239, 255, 255), got rgab(255, 255, 255, 255)
===================== 1 failed, 121 passed, 3 xfailed in 14.28 seconds ======================

gdk-pixbuf2 in Slackware 13.37 is version 2.23.3 and in Slackware 14 beta version 2.26.1. When running the test suite on 13.37 I get 40 failed tests, not sure if I should place the output here, as it is really long. On 14 beta sometimes I get segfault (first dmesg output):

py.test[2588]: segfault at 0 ip 00007f8fe81a11b2 sp 00007fff88f6a130 error 4 in _gi.so[7f8fe8189000+1e000]
==================================== test session starts ====================================
platform linux2 -- Python 2.7.3 -- pytest-2.2.4
collected 125 items 

tests/test_api.py .......
tests/test_boxes.py ....................
tests/test_css.py ...........
tests/test_css_validation.py ............
tests/test_draw.py ..Segmentation fault

And sometimes the following:

==================================== test session starts ====================================
platform linux2 -- Python 2.7.3 -- pytest-2.2.4
collected 125 items 

tests/test_api.py .......
tests/test_boxes.py ....................
tests/test_css.py ...........
tests/test_css_validation.py ............
tests/test_draw.py ..F.x.x..........x
tests/test_layout.py .............................................
tests/test_pdf.py .....
tests/test_stacking.py ..
tests/test_text.py .....

========================================= FAILURES ==========================================
_____________________________________ test_before_after _____________________________________
Traceback (most recent call last):
  File "/home/audrius/src/WeasyPrint/weasyprint/tests/testing_utils.py", line 99, in wrapper
    function()
  File "/home/audrius/src/WeasyPrint/weasyprint/tests/test_draw.py", line 1483, in test_before_after
    ], tolerance=10)
  File "/home/audrius/src/WeasyPrint/weasyprint/tests/test_draw.py", line 85, in assert_same_rendering
    reference, lines, tolerance)
  File "/home/audrius/src/WeasyPrint/weasyprint/tests/test_draw.py", line 179, in assert_pixels_equal
    % (x, y, name, expected_pixel, pixel))
AssertionError: Pixel (3, 194) in pseudo_quotes_reference: expected rgba(195, 239, 255), got rgab(255, 255, 255)
===================== 1 failed, 121 passed, 3 xfailed in 13.78 seconds ======================

from weasyprint.

SimonSapin avatar SimonSapin commented on May 30, 2024

Ok, I push yet a few more fixes. It turns out that mimetypes.add_type() really wants native strings (bytes on 2.x, Unicode on 3.x).

Introspection is broken in gdk-pixbuf2 before 2.25.0. I can reproduce dozens of failures by downgrading to 2.24.1 on my machine. I added a warning for that (and the same for Pango.)

I made PyGTK the default (when available), this should be safer. It would be nice however to also test with introspection:

python -m weasyprint.tests.gobject assert_pygtk && echo OK
py.test
WEASYPRINT_USE_INTROSPECTION=1 python -m weasyprint.tests.gobject assert_introspection && echo OK
WEASYPRINT_USE_INTROSPECTION=1 py.test

Alternatively, if you’re running Python 2.7 or adapt the tox.ini file:

pip install tox
tox -e py27-pygtk,py27-introspection

Note that only introspection is available on Python 3.

On 14 beta sometimes I get segfault

Oh great, a Heisenbug. I haven’t looked into this one yet.

from weasyprint.

audriusk avatar audriusk commented on May 30, 2024

Nice, now all tests pass using both PyGTK and PyGObject with introspection on Slackware 14 beta, and only PyGTK on Slackware 13.37 (no gobject-introspection available here). Thanks!

Tried running test suite multiple times, but couldn't get segfault this time. Maybe it's gone for good now.

from weasyprint.

SimonSapin avatar SimonSapin commented on May 30, 2024

Great! On which branch is that?

from weasyprint.

audriusk avatar audriusk commented on May 30, 2024

I tested on master only. Should I test on pixbuf as well?

from weasyprint.

SimonSapin avatar SimonSapin commented on May 30, 2024

If you’re not fed up with this, please do :)
I intend to merge pixbuf into master Soon® if it works well. Everything looked fine on my machine, but you helped discover tons of bugs.

from weasyprint.

audriusk avatar audriusk commented on May 30, 2024

OK, on Slackware 14 beta (gdk-pixbuf2-2.26.1) everything's fine, but on Slackware 13.37 (gdk-pixbuf2-2.23.3) 20 tests fail, seems that all of them with GError: Unrecognized image file format exception, unless I missed others. Here's the last three tracebacks (going to skip the others due to length):

___________________________________ test_background_size ____________________________________
Traceback (most recent call last):
  File "/root/WeasyPrint/weasyprint/tests/testing_utils.py", line 99, in wrapper
    function()
  File "/root/WeasyPrint/weasyprint/tests/test_draw.py", line 741, in test_background_size
    ''')
  File "/root/WeasyPrint/weasyprint/tests/test_draw.py", line 62, in assert_pixels
    html, nb_pages=nb_pages)
  File "/root/WeasyPrint/weasyprint/tests/test_draw.py", line 128, in html_to_pixels
    expected_height, nb_pages=nb_pages)
  File "/root/WeasyPrint/weasyprint/tests/test_draw.py", line 138, in document_to_pixels
    return png_to_pixels(document.write_png(), expected_width, expected_height)
  File "/root/WeasyPrint/weasyprint/tests/test_draw.py", line 142, in png_to_pixels
    pixbuf = get_pixbuf(string=png_bytes)
  File "/root/WeasyPrint/weasyprint/images.py", line 110, in get_pixbuf
    loader.close()
GError: Unrecognized image file format
___________________________________ test_background_image ___________________________________
Traceback (most recent call last):
  File "/root/WeasyPrint/weasyprint/tests/testing_utils.py", line 99, in wrapper
    function()
  File "/root/WeasyPrint/weasyprint/tests/test_draw.py", line 588, in test_background_image
    ''' % (css,))
  File "/root/WeasyPrint/weasyprint/tests/test_draw.py", line 62, in assert_pixels
    html, nb_pages=nb_pages)
  File "/root/WeasyPrint/weasyprint/tests/test_draw.py", line 128, in html_to_pixels
    expected_height, nb_pages=nb_pages)
  File "/root/WeasyPrint/weasyprint/tests/test_draw.py", line 138, in document_to_pixels
    return png_to_pixels(document.write_png(), expected_width, expected_height)
  File "/root/WeasyPrint/weasyprint/tests/test_draw.py", line 142, in png_to_pixels
    pixbuf = get_pixbuf(string=png_bytes)
  File "/root/WeasyPrint/weasyprint/images.py", line 110, in get_pixbuf
    loader.close()
GError: Unrecognized image file format
________________________________________ test_images ________________________________________
Traceback (most recent call last):
  File "/root/WeasyPrint/weasyprint/tests/testing_utils.py", line 99, in wrapper
    function()
  File "/root/WeasyPrint/weasyprint/tests/test_layout.py", line 2155, in test_images
    body, img = get_img(html)
  File "/root/WeasyPrint/weasyprint/tests/test_layout.py", line 2133, in get_img
    line, = body.children
ValueError: need more than 0 values to unpack
-------------------------------------- Captured stderr --------------------------------------
1 errors logged:
WARNING: Error for image at file:///root/WeasyPrint/weasyprint/tests/resources/pattern.gif : GError('Unrecognized image file format',)

from weasyprint.

SimonSapin avatar SimonSapin commented on May 30, 2024

I could not reproduce this bug, even on Ubuntu 10.04 with GTK 2.20 (pixbuf was not even a separate package.)

I get the same “Unrecognized image file format” message when trying to load a 0-byte image, and changed WeasyPrint to give a specific error message in that case. Are failures still the same? If they are, it seems like your version of pixbuf does not support PNG or GIF files, which would be surprising.

(I also merged the pixbuf branch into master and removed the former.)

from weasyprint.

audriusk avatar audriusk commented on May 30, 2024

Figured out why tests were failing for me on Slackware 13.37: XDG_DATA_DIRS environment variable was missing in my LXC container. After export XDG_DATA_DIRS=/usr/share:/usr/local/share all tests pass. Sorry for false alarm.

Now I can confidently say that everything's good on both 13.37 and 14 beta using latest master.

from weasyprint.

SimonSapin avatar SimonSapin commented on May 30, 2024

I’m not sure how this variable influences the supported images formats but what matters is that it works now. Thanks again!

from weasyprint.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.