Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests do not pass with Cairo development snapshots #1291

Closed
eli-schwartz opened this issue Jan 22, 2021 · 13 comments
Closed

Tests do not pass with Cairo development snapshots #1291

eli-schwartz opened this issue Jan 22, 2021 · 13 comments
Labels
bug Existing features not working as expected

Comments

@eli-schwartz
Copy link
Contributor

I'm trying to get an Arch Linux PKGBUILD to build weasyprint. The unittests won't pass though, with the following error:

=================================== FAILURES ===================================
______________________________ test_document_info ______________________________

    @assert_no_logs
    @requires('cairo', (1, 15, 4))
    def test_document_info():
        fileobj = io.BytesIO()
        FakeHTML(string='''
          <meta name=author content="I Me &amp; Myself">
          <title>Test document</title>
          <h1>Another title</h1>
          <meta name=generator content="Human after all">
          <meta name=keywords content="html ,\tcss,
                                       pdf,css">
          <meta name=description content="Blah… ">
          <meta name=dcterms.created content=2011-04-21T23:00:00Z>
          <meta name=dcterms.modified content=2013-07-21T23:46+01:00>
        ''').write_pdf(target=fileobj)
        info = pdf.PDFFile(fileobj).info
        assert info.get_value('Author', '(.*)') == b'(I Me & Myself)'
        assert info.get_value('Title', '(.*)') == b'(Test document)'
        assert info.get_value('Creator', '(.*)') == (
            b'<FEFF00480075006D0061006E00A00061006600740065007200A00061006C006C>')
        assert info.get_value('Keywords', '(.*)') == b'(html, css, pdf)'
        assert info.get_value('Subject', '(.*)') == (
            b'<FEFF0042006C0061006820260020>')
>       assert info.get_value('CreationDate', '(.*)') == b"(20110421230000+00'00)"
E       assert b"(20110421230000+00'00')" == b"(20110421230000+00'00)"
E         At index 21 diff: b"'" != b')'
E         Use -v to get the full diff

/build/python-weasyprint/src/WeasyPrint-52.2/weasyprint/tests/test_pdf.py:654: AssertionError
------------------------------ Captured log call -------------------------------
INFO     weasyprint.progress:__init__.py:103 Step 1 - Fetching and parsing HTML - HTML string
INFO     weasyprint.progress:__init__.py:64 Step 3 - Applying CSS
INFO     weasyprint.progress:document.py:380 Step 4 - Creating formatting structure
INFO     weasyprint.progress:pages.py:794 Step 5 - Creating layout - Page 1
INFO     weasyprint.progress:document.py:640 Step 6 - Drawing
INFO     weasyprint.progress:document.py:658 Step 7 - Adding PDF metadata
______________________________ test_float_inline _______________________________

    @assert_no_logs
    def test_float_inline():
>       assert_pixels('float_inline', 15, 5, '''
            rBBBGG_____aaaa
            BBBBGG_____aaaa
            BBBB_______aaaa
            BBBB_______aaaa
            _______________
        ''', '''
          <style>
            @font-face {src: url(AHEM____.TTF); font-family: ahem}
            @page { size: 15px 5px; background: white }
            body { font-family: ahem; font-size: 2px; line-height: 1; color: lime }
          </style>
          <div>
            <img style="float: left" src="pattern.png">
            <img style="float: right" src="blue.jpg">
            <span>a</span>
          </div>
        ''')

/build/python-weasyprint/src/WeasyPrint-52.2/weasyprint/tests/test_draw/test_float.py:55: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/build/python-weasyprint/src/WeasyPrint-52.2/weasyprint/tests/test_draw/__init__.py:57: in assert_pixels
    assert_pixels_equal(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

name = 'float_inline', width = 15, height = 5
raw = b'\x00\x00\xff\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\xff\xff\xff\xff\xff...ff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff'
expected_raw = b'\x00\x00\xff\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\xff\xff\xff\xff\xff...ff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff'
tolerance = 0

    def assert_pixels_equal(name, width, height, raw, expected_raw, tolerance=0):
        """Take 2 matrices of pixels and assert that they are the same."""
        if raw != expected_raw:  # pragma: no cover
            for i, (value, expected) in enumerate(zip(raw, expected_raw)):
                if abs(value - expected) > tolerance:
                    write_png(name, raw, width, height)
                    write_png(name + '.expected', expected_raw,
                              width, height)
                    pixel_n = i // 4
                    x = pixel_n // width
                    y = pixel_n % width
                    i % 4
                    pixel = tuple(list(raw[i:i + 4]))
                    expected_pixel = tuple(list(
                        expected_raw[i:i + 4]))
>                   assert 0, (
                        'Pixel (%i, %i) in %s: expected rgba%s, got rgba%s'
                        % (x, y, name, expected_pixel, pixel))
E                   AssertionError: Pixel (1, 4) in float_inline: expected rgba(0, 255, 0, 255), got rgba(127, 255, 127, 255)

/build/python-weasyprint/src/WeasyPrint-52.2/weasyprint/tests/test_draw/__init__.py:160: AssertionError
------------------------------ Captured log call -------------------------------
INFO     weasyprint.progress:__init__.py:103 Step 1 - Fetching and parsing HTML - HTML string
INFO     weasyprint.progress:__init__.py:349 Step 2 - Fetching and parsing CSS - CSS string
INFO     weasyprint.progress:__init__.py:64 Step 3 - Applying CSS
INFO     weasyprint.progress:document.py:380 Step 4 - Creating formatting structure
INFO     weasyprint.progress:pages.py:794 Step 5 - Creating layout - Page 1
INFO     weasyprint.progress:document.py:775 Step 6 - Drawing
____________________________ test_float_inline_rtl _____________________________

    @assert_no_logs
    def test_float_inline_rtl():
>       assert_pixels('float_inline_rtl', 15, 5, '''
            rBBB_____GGaaaa
            BBBB_____GGaaaa
            BBBB_______aaaa
            BBBB_______aaaa
            _______________
        ''', '''
          <style>
            @font-face {src: url(AHEM____.TTF); font-family: ahem}
            @page { size: 15px 5px; background: white }
            body { font-family: ahem; font-size: 2px; line-height: 1; color: lime }
          </style>
          <div style="direction: rtl">
            <img style="float: left" src="pattern.png">
            <img style="float: right" src="blue.jpg">
            <span>a</span>
          </div>
        ''')

/build/python-weasyprint/src/WeasyPrint-52.2/weasyprint/tests/test_draw/test_float.py:77: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/build/python-weasyprint/src/WeasyPrint-52.2/weasyprint/tests/test_draw/__init__.py:57: in assert_pixels
    assert_pixels_equal(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

name = 'float_inline_rtl', width = 15, height = 5
raw = b'\x00\x00\xff\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff...ff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff'
expected_raw = b'\x00\x00\xff\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff...ff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff'
tolerance = 0

    def assert_pixels_equal(name, width, height, raw, expected_raw, tolerance=0):
        """Take 2 matrices of pixels and assert that they are the same."""
        if raw != expected_raw:  # pragma: no cover
            for i, (value, expected) in enumerate(zip(raw, expected_raw)):
                if abs(value - expected) > tolerance:
                    write_png(name, raw, width, height)
                    write_png(name + '.expected', expected_raw,
                              width, height)
                    pixel_n = i // 4
                    x = pixel_n // width
                    y = pixel_n % width
                    i % 4
                    pixel = tuple(list(raw[i:i + 4]))
                    expected_pixel = tuple(list(
                        expected_raw[i:i + 4]))
>                   assert 0, (
                        'Pixel (%i, %i) in %s: expected rgba%s, got rgba%s'
                        % (x, y, name, expected_pixel, pixel))
E                   AssertionError: Pixel (1, 9) in float_inline_rtl: expected rgba(0, 255, 0, 255), got rgba(127, 255, 127, 255)

/build/python-weasyprint/src/WeasyPrint-52.2/weasyprint/tests/test_draw/__init__.py:160: AssertionError
------------------------------ Captured log call -------------------------------
INFO     weasyprint.progress:__init__.py:103 Step 1 - Fetching and parsing HTML - HTML string
INFO     weasyprint.progress:__init__.py:349 Step 2 - Fetching and parsing CSS - CSS string
INFO     weasyprint.progress:__init__.py:64 Step 3 - Applying CSS
INFO     weasyprint.progress:document.py:380 Step 4 - Creating formatting structure
INFO     weasyprint.progress:pages.py:794 Step 5 - Creating layout - Page 1
INFO     weasyprint.progress:document.py:775 Step 6 - Drawing
___________________________ test_float_inline_block ____________________________

    @assert_no_logs
    def test_float_inline_block():
>       assert_pixels('float_inline_block', 15, 5, '''
            rBBBGG_____aaaa
            BBBBGG_____aaaa
            BBBB_______aaaa
            BBBB_______aaaa
            _______________
        ''', '''
          <style>
            @font-face {src: url(AHEM____.TTF); font-family: ahem}
            @page { size: 15px 5px; background: white }
            body { font-family: ahem; font-size: 2px; line-height: 1; color: lime }
          </style>
          <div>
            <img style="float: left" src="pattern.png">
            <img style="float: right" src="blue.jpg">
            <span style="display: inline-block">a</span>
          </div>
        ''')

/build/python-weasyprint/src/WeasyPrint-52.2/weasyprint/tests/test_draw/test_float.py:99: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/build/python-weasyprint/src/WeasyPrint-52.2/weasyprint/tests/test_draw/__init__.py:57: in assert_pixels
    assert_pixels_equal(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

name = 'float_inline_block', width = 15, height = 5
raw = b'\x00\x00\xff\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\xff\xff\xff\xff\xff...ff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff'
expected_raw = b'\x00\x00\xff\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\xff\xff\xff\xff\xff...ff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff'
tolerance = 0

    def assert_pixels_equal(name, width, height, raw, expected_raw, tolerance=0):
        """Take 2 matrices of pixels and assert that they are the same."""
        if raw != expected_raw:  # pragma: no cover
            for i, (value, expected) in enumerate(zip(raw, expected_raw)):
                if abs(value - expected) > tolerance:
                    write_png(name, raw, width, height)
                    write_png(name + '.expected', expected_raw,
                              width, height)
                    pixel_n = i // 4
                    x = pixel_n // width
                    y = pixel_n % width
                    i % 4
                    pixel = tuple(list(raw[i:i + 4]))
                    expected_pixel = tuple(list(
                        expected_raw[i:i + 4]))
>                   assert 0, (
                        'Pixel (%i, %i) in %s: expected rgba%s, got rgba%s'
                        % (x, y, name, expected_pixel, pixel))
E                   AssertionError: Pixel (1, 4) in float_inline_block: expected rgba(0, 255, 0, 255), got rgba(127, 255, 127, 255)

/build/python-weasyprint/src/WeasyPrint-52.2/weasyprint/tests/test_draw/__init__.py:160: AssertionError
------------------------------ Captured log call -------------------------------
INFO     weasyprint.progress:__init__.py:103 Step 1 - Fetching and parsing HTML - HTML string
INFO     weasyprint.progress:__init__.py:349 Step 2 - Fetching and parsing CSS - CSS string
INFO     weasyprint.progress:__init__.py:64 Step 3 - Applying CSS
INFO     weasyprint.progress:document.py:380 Step 4 - Creating formatting structure
INFO     weasyprint.progress:pages.py:794 Step 5 - Creating layout - Page 1
INFO     weasyprint.progress:document.py:775 Step 6 - Drawing
_________________________ test_float_inline_block_rtl __________________________

    @assert_no_logs
    def test_float_inline_block_rtl():
>       assert_pixels('float_inline_block_rtl', 15, 5, '''
            rBBB_____GGaaaa
            BBBB_____GGaaaa
            BBBB_______aaaa
            BBBB_______aaaa
            _______________
        ''', '''
          <style>
            @font-face {src: url(AHEM____.TTF); font-family: ahem}
            @page { size: 15px 5px; background: white }
            body { font-family: ahem; font-size: 2px; line-height: 1; color: lime }
          </style>
          <div style="direction: rtl">
            <img style="float: left" src="pattern.png">
            <img style="float: right" src="blue.jpg">
            <span style="display: inline-block">a</span>
          </div>
        ''')

/build/python-weasyprint/src/WeasyPrint-52.2/weasyprint/tests/test_draw/test_float.py:121: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/build/python-weasyprint/src/WeasyPrint-52.2/weasyprint/tests/test_draw/__init__.py:57: in assert_pixels
    assert_pixels_equal(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

name = 'float_inline_block_rtl', width = 15, height = 5
raw = b'\x00\x00\xff\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff...ff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff'
expected_raw = b'\x00\x00\xff\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff...ff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff'
tolerance = 0

    def assert_pixels_equal(name, width, height, raw, expected_raw, tolerance=0):
        """Take 2 matrices of pixels and assert that they are the same."""
        if raw != expected_raw:  # pragma: no cover
            for i, (value, expected) in enumerate(zip(raw, expected_raw)):
                if abs(value - expected) > tolerance:
                    write_png(name, raw, width, height)
                    write_png(name + '.expected', expected_raw,
                              width, height)
                    pixel_n = i // 4
                    x = pixel_n // width
                    y = pixel_n % width
                    i % 4
                    pixel = tuple(list(raw[i:i + 4]))
                    expected_pixel = tuple(list(
                        expected_raw[i:i + 4]))
>                   assert 0, (
                        'Pixel (%i, %i) in %s: expected rgba%s, got rgba%s'
                        % (x, y, name, expected_pixel, pixel))
E                   AssertionError: Pixel (1, 9) in float_inline_block_rtl: expected rgba(0, 255, 0, 255), got rgba(127, 255, 127, 255)

/build/python-weasyprint/src/WeasyPrint-52.2/weasyprint/tests/test_draw/__init__.py:160: AssertionError
------------------------------ Captured log call -------------------------------
INFO     weasyprint.progress:__init__.py:103 Step 1 - Fetching and parsing HTML - HTML string
INFO     weasyprint.progress:__init__.py:349 Step 2 - Fetching and parsing CSS - CSS string
INFO     weasyprint.progress:__init__.py:64 Step 3 - Applying CSS
INFO     weasyprint.progress:document.py:380 Step 4 - Creating formatting structure
INFO     weasyprint.progress:pages.py:794 Step 5 - Creating layout - Page 1
INFO     weasyprint.progress:document.py:775 Step 6 - Drawing
_______________________________ test_float_table _______________________________

    @assert_no_logs
    def test_float_table():
>       assert_pixels('float_table', 15, 5, '''
            rBBBGG_____aaaa
            BBBBGG_____aaaa
            BBBB_______aaaa
            BBBB_______aaaa
            _______________
        ''', '''
          <style>
            @font-face {src: url(AHEM____.TTF); font-family: ahem}
            @page { size: 15px 5px; background: white }
            body { font-family: ahem; font-size: 2px; line-height: 1; color: lime }
          </style>
          <div>
            <img style="float: left" src="pattern.png">
            <img style="float: right" src="blue.jpg">
            <table><tbody><tr><td>a</td></tr></tbody></table>
          </div>
        ''')

/build/python-weasyprint/src/WeasyPrint-52.2/weasyprint/tests/test_draw/test_float.py:143: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/build/python-weasyprint/src/WeasyPrint-52.2/weasyprint/tests/test_draw/__init__.py:57: in assert_pixels
    assert_pixels_equal(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

name = 'float_table', width = 15, height = 5
raw = b'\x00\x00\xff\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\xff\xff\xff\xff\xff...ff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff'
expected_raw = b'\x00\x00\xff\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\xff\xff\xff\xff\xff...ff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff'
tolerance = 0

    def assert_pixels_equal(name, width, height, raw, expected_raw, tolerance=0):
        """Take 2 matrices of pixels and assert that they are the same."""
        if raw != expected_raw:  # pragma: no cover
            for i, (value, expected) in enumerate(zip(raw, expected_raw)):
                if abs(value - expected) > tolerance:
                    write_png(name, raw, width, height)
                    write_png(name + '.expected', expected_raw,
                              width, height)
                    pixel_n = i // 4
                    x = pixel_n // width
                    y = pixel_n % width
                    i % 4
                    pixel = tuple(list(raw[i:i + 4]))
                    expected_pixel = tuple(list(
                        expected_raw[i:i + 4]))
>                   assert 0, (
                        'Pixel (%i, %i) in %s: expected rgba%s, got rgba%s'
                        % (x, y, name, expected_pixel, pixel))
E                   AssertionError: Pixel (1, 4) in float_table: expected rgba(0, 255, 0, 255), got rgba(127, 255, 127, 255)

/build/python-weasyprint/src/WeasyPrint-52.2/weasyprint/tests/test_draw/__init__.py:160: AssertionError
------------------------------ Captured log call -------------------------------
INFO     weasyprint.progress:__init__.py:103 Step 1 - Fetching and parsing HTML - HTML string
INFO     weasyprint.progress:__init__.py:349 Step 2 - Fetching and parsing CSS - CSS string
INFO     weasyprint.progress:__init__.py:64 Step 3 - Applying CSS
INFO     weasyprint.progress:document.py:380 Step 4 - Creating formatting structure
INFO     weasyprint.progress:pages.py:794 Step 5 - Creating layout - Page 1
INFO     weasyprint.progress:document.py:775 Step 6 - Drawing
_____________________________ test_float_table_rtl _____________________________

    @assert_no_logs
    def test_float_table_rtl():
>       assert_pixels('float_table_rtl', 15, 5, '''
            rBBB_____GGaaaa
            BBBB_____GGaaaa
            BBBB_______aaaa
            BBBB_______aaaa
            _______________
        ''', '''
          <style>
            @font-face {src: url(AHEM____.TTF); font-family: ahem}
            @page { size: 15px 5px; background: white }
            body { font-family: ahem; font-size: 2px; line-height: 1; color: lime }
          </style>
          <div style="direction: rtl">
            <img style="float: left" src="pattern.png">
            <img style="float: right" src="blue.jpg">
            <table><tbody><tr><td>a</td></tr></tbody></table>
          </div>
        ''')

/build/python-weasyprint/src/WeasyPrint-52.2/weasyprint/tests/test_draw/test_float.py:165: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/build/python-weasyprint/src/WeasyPrint-52.2/weasyprint/tests/test_draw/__init__.py:57: in assert_pixels
    assert_pixels_equal(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

name = 'float_table_rtl', width = 15, height = 5
raw = b'\x00\x00\xff\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff...ff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff'
expected_raw = b'\x00\x00\xff\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff...ff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff'
tolerance = 0

    def assert_pixels_equal(name, width, height, raw, expected_raw, tolerance=0):
        """Take 2 matrices of pixels and assert that they are the same."""
        if raw != expected_raw:  # pragma: no cover
            for i, (value, expected) in enumerate(zip(raw, expected_raw)):
                if abs(value - expected) > tolerance:
                    write_png(name, raw, width, height)
                    write_png(name + '.expected', expected_raw,
                              width, height)
                    pixel_n = i // 4
                    x = pixel_n // width
                    y = pixel_n % width
                    i % 4
                    pixel = tuple(list(raw[i:i + 4]))
                    expected_pixel = tuple(list(
                        expected_raw[i:i + 4]))
>                   assert 0, (
                        'Pixel (%i, %i) in %s: expected rgba%s, got rgba%s'
                        % (x, y, name, expected_pixel, pixel))
E                   AssertionError: Pixel (1, 9) in float_table_rtl: expected rgba(0, 255, 0, 255), got rgba(127, 255, 127, 255)

/build/python-weasyprint/src/WeasyPrint-52.2/weasyprint/tests/test_draw/__init__.py:160: AssertionError
------------------------------ Captured log call -------------------------------
INFO     weasyprint.progress:__init__.py:103 Step 1 - Fetching and parsing HTML - HTML string
INFO     weasyprint.progress:__init__.py:349 Step 2 - Fetching and parsing CSS - CSS string
INFO     weasyprint.progress:__init__.py:64 Step 3 - Applying CSS
INFO     weasyprint.progress:document.py:380 Step 4 - Creating formatting structure
INFO     weasyprint.progress:pages.py:794 Step 5 - Creating layout - Page 1
INFO     weasyprint.progress:document.py:775 Step 6 - Drawing
___________________________ test_float_inline_table ____________________________

    @assert_no_logs
    def test_float_inline_table():
>       assert_pixels('float_inline_table', 15, 5, '''
            rBBBGG_____aaaa
            BBBBGG_____aaaa
            BBBB_______aaaa
            BBBB_______aaaa
            _______________
        ''', '''
          <style>
            @font-face {src: url(AHEM____.TTF); font-family: ahem}
            @page { size: 15px 5px; background: white }
            table { display: inline-table }
            body { font-family: ahem; font-size: 2px; line-height: 1; color: lime }
          </style>
          <div>
            <img style="float: left" src="pattern.png">
            <img style="float: right" src="blue.jpg">
            <table><tbody><tr><td>a</td></tr></tbody></table>
          </div>
        ''')

/build/python-weasyprint/src/WeasyPrint-52.2/weasyprint/tests/test_draw/test_float.py:187: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/build/python-weasyprint/src/WeasyPrint-52.2/weasyprint/tests/test_draw/__init__.py:57: in assert_pixels
    assert_pixels_equal(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

name = 'float_inline_table', width = 15, height = 5
raw = b'\x00\x00\xff\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\xff\xff\xff\xff\xff...ff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff'
expected_raw = b'\x00\x00\xff\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\xff\xff\xff\xff\xff...ff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff'
tolerance = 0

    def assert_pixels_equal(name, width, height, raw, expected_raw, tolerance=0):
        """Take 2 matrices of pixels and assert that they are the same."""
        if raw != expected_raw:  # pragma: no cover
            for i, (value, expected) in enumerate(zip(raw, expected_raw)):
                if abs(value - expected) > tolerance:
                    write_png(name, raw, width, height)
                    write_png(name + '.expected', expected_raw,
                              width, height)
                    pixel_n = i // 4
                    x = pixel_n // width
                    y = pixel_n % width
                    i % 4
                    pixel = tuple(list(raw[i:i + 4]))
                    expected_pixel = tuple(list(
                        expected_raw[i:i + 4]))
>                   assert 0, (
                        'Pixel (%i, %i) in %s: expected rgba%s, got rgba%s'
                        % (x, y, name, expected_pixel, pixel))
E                   AssertionError: Pixel (1, 4) in float_inline_table: expected rgba(0, 255, 0, 255), got rgba(127, 255, 127, 255)

/build/python-weasyprint/src/WeasyPrint-52.2/weasyprint/tests/test_draw/__init__.py:160: AssertionError
------------------------------ Captured log call -------------------------------
INFO     weasyprint.progress:__init__.py:103 Step 1 - Fetching and parsing HTML - HTML string
INFO     weasyprint.progress:__init__.py:349 Step 2 - Fetching and parsing CSS - CSS string
INFO     weasyprint.progress:__init__.py:64 Step 3 - Applying CSS
INFO     weasyprint.progress:document.py:380 Step 4 - Creating formatting structure
INFO     weasyprint.progress:pages.py:794 Step 5 - Creating layout - Page 1
INFO     weasyprint.progress:document.py:775 Step 6 - Drawing
_________________________ test_float_inline_table_rtl __________________________

    @assert_no_logs
    def test_float_inline_table_rtl():
>       assert_pixels('float_inline_table_rtl', 15, 5, '''
            rBBB_____GGaaaa
            BBBB_____GGaaaa
            BBBB_______aaaa
            BBBB_______aaaa
            _______________
        ''', '''
          <style>
            @font-face {src: url(AHEM____.TTF); font-family: ahem}
            @page { size: 15px 5px; background: white }
            table { display: inline-table }
            body { font-family: ahem; font-size: 2px; line-height: 1; color: lime }
          </style>
          <div style="direction: rtl">
            <img style="float: left" src="pattern.png">
            <img style="float: right" src="blue.jpg">
            <table><tbody><tr><td>a</td></tr></tbody></table>
          </div>
        ''')

/build/python-weasyprint/src/WeasyPrint-52.2/weasyprint/tests/test_draw/test_float.py:210: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/build/python-weasyprint/src/WeasyPrint-52.2/weasyprint/tests/test_draw/__init__.py:57: in assert_pixels
    assert_pixels_equal(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

name = 'float_inline_table_rtl', width = 15, height = 5
raw = b'\x00\x00\xff\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff...ff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff'
expected_raw = b'\x00\x00\xff\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff...ff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff'
tolerance = 0

    def assert_pixels_equal(name, width, height, raw, expected_raw, tolerance=0):
        """Take 2 matrices of pixels and assert that they are the same."""
        if raw != expected_raw:  # pragma: no cover
            for i, (value, expected) in enumerate(zip(raw, expected_raw)):
                if abs(value - expected) > tolerance:
                    write_png(name, raw, width, height)
                    write_png(name + '.expected', expected_raw,
                              width, height)
                    pixel_n = i // 4
                    x = pixel_n // width
                    y = pixel_n % width
                    i % 4
                    pixel = tuple(list(raw[i:i + 4]))
                    expected_pixel = tuple(list(
                        expected_raw[i:i + 4]))
>                   assert 0, (
                        'Pixel (%i, %i) in %s: expected rgba%s, got rgba%s'
                        % (x, y, name, expected_pixel, pixel))
E                   AssertionError: Pixel (1, 9) in float_inline_table_rtl: expected rgba(0, 255, 0, 255), got rgba(127, 255, 127, 255)

/build/python-weasyprint/src/WeasyPrint-52.2/weasyprint/tests/test_draw/__init__.py:160: AssertionError
------------------------------ Captured log call -------------------------------
INFO     weasyprint.progress:__init__.py:103 Step 1 - Fetching and parsing HTML - HTML string
INFO     weasyprint.progress:__init__.py:349 Step 2 - Fetching and parsing CSS - CSS string
INFO     weasyprint.progress:__init__.py:64 Step 3 - Applying CSS
INFO     weasyprint.progress:document.py:380 Step 4 - Creating formatting structure
INFO     weasyprint.progress:pages.py:794 Step 5 - Creating layout - Page 1
INFO     weasyprint.progress:document.py:775 Step 6 - Drawing
___________________________ test_text_overflow_clip ____________________________

    def test_text_overflow_clip():
>       assert_pixels('text_overflow', 9, 7, '''
            _________
            _RRRRRRR_
            _RRRRRRR_
            _________
            _RR__RRR_
            _RR__RRR_
            _________
        ''', '''
          <style>
            @font-face {src: url(AHEM____.TTF); font-family: ahem}
            @page {
              size: 9px 7px;
              background: white;
            }
            body {
              color: red;
              font-family: ahem;
              font-size: 2px;
            }
            div {
              line-height: 1;
              margin: 1px;
              overflow: hidden;
              width: 3.5em;
            }
          </style>
          <div>abcde</div>
          <div style="white-space: nowrap">a bcde</div>''')

/build/python-weasyprint/src/WeasyPrint-52.2/weasyprint/tests/test_draw/test_text.py:13: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/build/python-weasyprint/src/WeasyPrint-52.2/weasyprint/tests/test_draw/__init__.py:57: in assert_pixels
    assert_pixels_equal(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

name = 'text_overflow', width = 9, height = 7
raw = b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff...ff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff'
expected_raw = b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff...ff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff'
tolerance = 0

    def assert_pixels_equal(name, width, height, raw, expected_raw, tolerance=0):
        """Take 2 matrices of pixels and assert that they are the same."""
        if raw != expected_raw:  # pragma: no cover
            for i, (value, expected) in enumerate(zip(raw, expected_raw)):
                if abs(value - expected) > tolerance:
                    write_png(name, raw, width, height)
                    write_png(name + '.expected', expected_raw,
                              width, height)
                    pixel_n = i // 4
                    x = pixel_n // width
                    y = pixel_n % width
                    i % 4
                    pixel = tuple(list(raw[i:i + 4]))
                    expected_pixel = tuple(list(
                        expected_raw[i:i + 4]))
>                   assert 0, (
                        'Pixel (%i, %i) in %s: expected rgba%s, got rgba%s'
                        % (x, y, name, expected_pixel, pixel))
E                   AssertionError: Pixel (2, 1) in text_overflow: expected rgba(0, 0, 255, 255), got rgba(127, 127, 255, 255)

/build/python-weasyprint/src/WeasyPrint-52.2/weasyprint/tests/test_draw/__init__.py:160: AssertionError
------------------------------ Captured log call -------------------------------
INFO     weasyprint.progress:__init__.py:103 Step 1 - Fetching and parsing HTML - HTML string
INFO     weasyprint.progress:__init__.py:349 Step 2 - Fetching and parsing CSS - CSS string
INFO     weasyprint.progress:__init__.py:64 Step 3 - Applying CSS
INFO     weasyprint.progress:document.py:380 Step 4 - Creating formatting structure
INFO     weasyprint.progress:pages.py:794 Step 5 - Creating layout - Page 1
INFO     weasyprint.progress:document.py:775 Step 6 - Drawing
_________________________ test_text_overflow_ellipsis __________________________

    def test_text_overflow_ellipsis():
>       assert_pixels('text_overflow', 9, 16, '''
            _________
            _RRRRRR__
            _RRRRRR__
            _________
            _RR__RR__
            _RR__RR__
            _________
            _RRRRRR__
            _RRRRRR__
            _________
            _RRRRRRR_
            _RRRRRRR_
            _________
            _RRRRRRR_
            _RRRRRRR_
            _________
        ''', '''
          <style>
            @font-face {src: url(AHEM____.TTF); font-family: ahem}
            @page {
              background: white;
              size: 9px 16px;
            }
            body {
              color: red;
              font-family: ahem;
              font-size: 2px;
            }
            div {
              line-height: 1;
              margin: 1px;
              overflow: hidden;
              text-overflow: ellipsis;
              width: 3.5em;
            }
            div div {
              margin: 0;
            }
          </style>
          <div>abcde</div>
          <div style="white-space: nowrap">a bcde</div>
          <div><span>a<span>b</span>cd</span>e</div>
          <div><div style="text-overflow: clip">abcde</div></div>
          <div><div style="overflow: visible">abcde</div></div>
    ''')

/build/python-weasyprint/src/WeasyPrint-52.2/weasyprint/tests/test_draw/test_text.py:45: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/build/python-weasyprint/src/WeasyPrint-52.2/weasyprint/tests/test_draw/__init__.py:57: in assert_pixels
    assert_pixels_equal(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

name = 'text_overflow', width = 9, height = 16
raw = b'\xff\xff\xff\xff\x7f\x7f\xff\xff\x7f\x7f\xff\xff\x7f\x7f\xff\xff\x7f\x7f\xff\xff\x7f\x7f\xff\xff\x7f\x7f\xff\xff\xff...ff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff'
expected_raw = b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff...ff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff'
tolerance = 0

    def assert_pixels_equal(name, width, height, raw, expected_raw, tolerance=0):
        """Take 2 matrices of pixels and assert that they are the same."""
        if raw != expected_raw:  # pragma: no cover
            for i, (value, expected) in enumerate(zip(raw, expected_raw)):
                if abs(value - expected) > tolerance:
                    write_png(name, raw, width, height)
                    write_png(name + '.expected', expected_raw,
                              width, height)
                    pixel_n = i // 4
                    x = pixel_n // width
                    y = pixel_n % width
                    i % 4
                    pixel = tuple(list(raw[i:i + 4]))
                    expected_pixel = tuple(list(
                        expected_raw[i:i + 4]))
>                   assert 0, (
                        'Pixel (%i, %i) in %s: expected rgba%s, got rgba%s'
                        % (x, y, name, expected_pixel, pixel))
E                   AssertionError: Pixel (0, 1) in text_overflow: expected rgba(255, 255, 255, 255), got rgba(127, 127, 255, 255)

/build/python-weasyprint/src/WeasyPrint-52.2/weasyprint/tests/test_draw/__init__.py:160: AssertionError
------------------------------ Captured log call -------------------------------
INFO     weasyprint.progress:__init__.py:103 Step 1 - Fetching and parsing HTML - HTML string
INFO     weasyprint.progress:__init__.py:349 Step 2 - Fetching and parsing CSS - CSS string
INFO     weasyprint.progress:__init__.py:64 Step 3 - Applying CSS
INFO     weasyprint.progress:document.py:380 Step 4 - Creating formatting structure
INFO     weasyprint.progress:pages.py:794 Step 5 - Creating layout - Page 1
INFO     weasyprint.progress:document.py:775 Step 6 - Drawing
___________________ test_text_align_rtl_trailing_whitespace ____________________

    def test_text_align_rtl_trailing_whitespace():
        # Test text alignment for rtl text with trailing space.
        # Test regression: https://github.com/Kozea/WeasyPrint/issues/1111
>       assert_pixels('text_overflow', 9, 9, '''
            _________
            _rrrrBBB_
            _________
            _rrrrBBB_
            _________
            _BBBrrrr_
            _________
            _BBBrrrr_
            _________
        ''', '''
          <style>
            @font-face {src: url(AHEM____.TTF); font-family: ahem}
            @page { background: white; size: 9px }
            body { font-family: ahem; color: blue; font-size: 1px }
            p { background: red; line-height: 1; width: 7em; margin: 1em }
          </style>
          <!-- &#8207 forces Unicode RTL direction for the following chars -->
          <p style="direction: rtl"> abc </p>
          <p style="direction: rtl"> &#8207;abc </p>
          <p style="direction: ltr"> abc </p>
          <p style="direction: ltr"> &#8207;abc </p>
        ''')

/build/python-weasyprint/src/WeasyPrint-52.2/weasyprint/tests/test_draw/test_text.py:96: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/build/python-weasyprint/src/WeasyPrint-52.2/weasyprint/tests/test_draw/__init__.py:57: in assert_pixels
    assert_pixels_equal(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

name = 'text_overflow', width = 9, height = 9
raw = b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7f\x7f\xff\xff\x7f\x7f\xff\xff...ff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff'
expected_raw = b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff...ff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff'
tolerance = 0

    def assert_pixels_equal(name, width, height, raw, expected_raw, tolerance=0):
        """Take 2 matrices of pixels and assert that they are the same."""
        if raw != expected_raw:  # pragma: no cover
            for i, (value, expected) in enumerate(zip(raw, expected_raw)):
                if abs(value - expected) > tolerance:
                    write_png(name, raw, width, height)
                    write_png(name + '.expected', expected_raw,
                              width, height)
                    pixel_n = i // 4
                    x = pixel_n // width
                    y = pixel_n % width
                    i % 4
                    pixel = tuple(list(raw[i:i + 4]))
                    expected_pixel = tuple(list(
                        expected_raw[i:i + 4]))
>                   assert 0, (
                        'Pixel (%i, %i) in %s: expected rgba%s, got rgba%s'
                        % (x, y, name, expected_pixel, pixel))
E                   AssertionError: Pixel (0, 5) in text_overflow: expected rgba(255, 255, 255, 255), got rgba(127, 127, 255, 255)

/build/python-weasyprint/src/WeasyPrint-52.2/weasyprint/tests/test_draw/__init__.py:160: AssertionError
------------------------------ Captured log call -------------------------------
INFO     weasyprint.progress:__init__.py:103 Step 1 - Fetching and parsing HTML - HTML string
INFO     weasyprint.progress:__init__.py:349 Step 2 - Fetching and parsing CSS - CSS string
INFO     weasyprint.progress:__init__.py:64 Step 3 - Applying CSS
INFO     weasyprint.progress:document.py:380 Step 4 - Creating formatting structure
INFO     weasyprint.progress:pages.py:794 Step 5 - Creating layout - Page 1
INFO     weasyprint.progress:document.py:775 Step 6 - Drawing
__________________________ test_table_vertical_align ___________________________

    @assert_no_logs
    @requires('cairo', (1, 12, 0))
    def test_table_vertical_align():
>       assert_pixels('table_vertical_align', 28, 10, '''
            rrrrrrrrrrrrrrrrrrrrrrrrrrrr
            rBBBBBBBBBBBBBBBBBBBBBBBBBBr
            rBrBB_BB_BB_BB_BBrrBBrrBB_Br
            rBrBB_BB_BBrBBrBBrrBBrrBBrBr
            rB_BBrBB_BBrBBrBBrrBBrrBBrBr
            rB_BBrBB_BB_BB_BBrrBBrrBB_Br
            rB_BB_BBrBB_BB_BB__BB__BB_Br
            rB_BB_BBrBB_BB_BB__BB__BB_Br
            rBBBBBBBBBBBBBBBBBBBBBBBBBBr
            rrrrrrrrrrrrrrrrrrrrrrrrrrrr
        ''', '''
          <style>
            @font-face { src: url(AHEM____.TTF); font-family: ahem }
            @page { size: 28px 10px }
            html { background: #fff; font-size: 1px; color: red }
            body { margin: 0; width: 28px; height: 10px }
            td {
              width: 1em;
              padding: 0 !important;
              border: 1px solid blue;
              line-height: 1em;
              font-family: ahem;
            }
          </style>
          <table style="border: 1px solid red; border-spacing: 0">
            <tr>
              <!-- Test vertical-align: top, auto height -->
              <td style="vertical-align: top">o o</td>
    
              <!-- Test vertical-align: middle, auto height -->
              <td style="vertical-align: middle">o o</td>
    
              <!-- Test vertical-align: bottom, fixed useless height -->
              <td style="vertical-align: bottom; height: 2em">o o</td>
    
              <!-- Test default vertical-align value (baseline),
                   fixed useless height -->
              <td style="height: 5em">o o</td>
    
              <!-- Test vertical-align: baseline with baseline set by next cell,
                   auto height -->
              <td style="vertical-align: baseline">o o</td>
    
              <!-- Set baseline height to 2px, auto height -->
              <td style="vertical-align: baseline; font-size: 2em">o o</td>
    
              <!-- Test padding-bottom, fixed useless height,
                   set the height of the cells to 2 lines * 2em + 2px = 6px -->
              <td style="vertical-align: baseline; height: 1em;
                         font-size: 2em; padding-bottom: 2px !important">
                o o
              </td>
    
              <!-- Test padding-top, auto height -->
              <td style="vertical-align: top; padding-top: 1em !important">
                o o
              </td>
            </tr>
          </table>
        ''')  # noqa

/build/python-weasyprint/src/WeasyPrint-52.2/weasyprint/tests/test_layout/test_table.py:1868: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/build/python-weasyprint/src/WeasyPrint-52.2/weasyprint/tests/test_draw/__init__.py:57: in assert_pixels
    assert_pixels_equal(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

name = 'table_vertical_align', width = 28, height = 10
raw = b'\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00...ff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff'
expected_raw = b'\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00...ff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff'
tolerance = 0

    def assert_pixels_equal(name, width, height, raw, expected_raw, tolerance=0):
        """Take 2 matrices of pixels and assert that they are the same."""
        if raw != expected_raw:  # pragma: no cover
            for i, (value, expected) in enumerate(zip(raw, expected_raw)):
                if abs(value - expected) > tolerance:
                    write_png(name, raw, width, height)
                    write_png(name + '.expected', expected_raw,
                              width, height)
                    pixel_n = i // 4
                    x = pixel_n // width
                    y = pixel_n % width
                    i % 4
                    pixel = tuple(list(raw[i:i + 4]))
                    expected_pixel = tuple(list(
                        expected_raw[i:i + 4]))
>                   assert 0, (
                        'Pixel (%i, %i) in %s: expected rgba%s, got rgba%s'
                        % (x, y, name, expected_pixel, pixel))
E                   AssertionError: Pixel (1, 2) in table_vertical_align: expected rgba(255, 0, 0, 255), got rgba(127, 0, 128, 255)

/build/python-weasyprint/src/WeasyPrint-52.2/weasyprint/tests/test_draw/__init__.py:160: AssertionError
------------------------------ Captured log call -------------------------------
INFO     weasyprint.progress:__init__.py:103 Step 1 - Fetching and parsing HTML - HTML string
INFO     weasyprint.progress:__init__.py:349 Step 2 - Fetching and parsing CSS - CSS string
INFO     weasyprint.progress:__init__.py:64 Step 3 - Applying CSS
INFO     weasyprint.progress:document.py:380 Step 4 - Creating formatting structure
INFO     weasyprint.progress:pages.py:794 Step 5 - Creating layout - Page 1
INFO     weasyprint.progress:document.py:775 Step 6 - Drawing
=============================== warnings summary ===============================
../../../../usr/lib/python3.9/site-packages/packaging/version.py:127: 240 warnings
  /usr/lib/python3.9/site-packages/packaging/version.py:127: DeprecationWarning: Creating a LegacyVersion has been deprecated and will be removed in the next major release
    warnings.warn(

-- Docs: https://docs.pytest.org/en/stable/warnings.html
=========================== short test summary info ============================
FAILED weasyprint/tests/test_pdf.py::test_document_info - assert b"(201104212...
FAILED weasyprint/tests/test_draw/test_float.py::test_float_inline - Assertio...
FAILED weasyprint/tests/test_draw/test_float.py::test_float_inline_rtl - Asse...
FAILED weasyprint/tests/test_draw/test_float.py::test_float_inline_block - As...
FAILED weasyprint/tests/test_draw/test_float.py::test_float_inline_block_rtl
FAILED weasyprint/tests/test_draw/test_float.py::test_float_table - Assertion...
FAILED weasyprint/tests/test_draw/test_float.py::test_float_table_rtl - Asser...
FAILED weasyprint/tests/test_draw/test_float.py::test_float_inline_table - As...
FAILED weasyprint/tests/test_draw/test_float.py::test_float_inline_table_rtl
FAILED weasyprint/tests/test_draw/test_text.py::test_text_overflow_clip - Ass...
FAILED weasyprint/tests/test_draw/test_text.py::test_text_overflow_ellipsis
FAILED weasyprint/tests/test_draw/test_text.py::test_text_align_rtl_trailing_whitespace
FAILED weasyprint/tests/test_layout/test_table.py::test_table_vertical_align
========== 13 failed, 1285 passed, 11 xfailed, 240 warnings in 31.51s ==========

I do have the dejavu fonts installed, as well as gdk-pixbuf2, pango, and all the python module dependencies.

PKGBUILD
# Maintainer: Eli Schwartz <[email protected]>

_pkgname=WeasyPrint
pkgname=python-weasyprint
pkgver=52.2
pkgrel=1
pkgdesc="visual rendering engine for HTML and CSS that can export to PDF and PNG"
arch=('any')
url="https://www.courtbouillon.org/weasyprint"
license=('BSD')
_py_deps=('cairocffi' 'cairosvg' 'cffi' 'cssselect2' 'html5lib' 'pillow'
          'pyphen' 'tinycss2')
depends=('gdk-pixbuf2' 'pango' "${_py_deps[@]/#/python-}")
makedepends=('python-setuptools')
checkdepends=('python-pytest' 'ttf-dejavu')
source=("https://files.pythonhosted.org/packages/source/${_pkgname:0:1}/${_pkgname}/${_pkgname}-${pkgver}.tar.gz")
sha256sums=('21a1a9f11650ed14241817bf333a0ae0a42f6ae38cd7c2654845cb17352b7434')
b2sums=('33a41593dd50c8f4a5738f9e41b570219d83a512a6c00ccc9b0fa9ddf4ab1040e1c5c95eada833810a9c6bc07efbacc5735f6a5e341a6b8b01b128651b5c4fa4')

prepare(){
    cd "${srcdir}"/${_pkgname}-${pkgver}

    # test requirements should not be needed during build if tests are disabled
    sed -i 's/setup_requires = pytest-runner//' setup.cfg

    # thou shalt not lint coding style in integration tests
    sed -i 's/--flake8 --isort//' setup.cfg
}

build(){
    cd "${srcdir}"/${_pkgname}-${pkgver}

    python setup.py build
}

check() {
    cd "${srcdir}"/${_pkgname}-${pkgver}

    python -m pytest
}

package() {
    cd "${srcdir}"/${_pkgname}-${pkgver}

    python setup.py install --root="${pkgdir}" --optimize=1 --skip-build
    install -Dm644 LICENSE "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE
}
@liZe
Copy link
Member

liZe commented Jan 23, 2021

Hello!

Tests don’t pass probably because you have Cairo 1.17.x. Tests only pass with Cairo 1.16.x.

@ddevault
Copy link

🤦

It should probably be the business of a project which depends extensively on Cairo to keep itself up to date with Cairo.

@liZe
Copy link
Member

liZe commented Jan 25, 2021

Please, be kind ❤️.

It should probably be the business of a project which depends extensively on Cairo to keep itself up to date with Cairo.

Actually, the master branch of WeasyPrint doesn’t depend on Cairo anymore.

Having tests passing with both Cairo 1.16.x (that’s still used on many distributions) and 1.17.x (that were marked as unstable when they were released) requires a lot of work. As Cairo suffers from technical and organizational problems (see Cairo’s mailing list), we decided to write our own PDF generator. It takes some time, that’s why there’s no release yet without Cairo.

You can read more about that on #1232 (the issue is pinned, you can’t miss it).

@eli-schwartz
Copy link
Contributor Author

Tests don’t pass probably because you have Cairo 1.17.x. Tests only pass with Cairo 1.16.x.

Thank you for confirming this is a bug in WeasyPrint.

As Cairo suffers from technical and organizational problems (see Cairo’s mailing list), we decided to write our own PDF generator. It takes some time, that’s why there’s no release yet without Cairo.

That's just an incredibly, incredibly weak argument. One person raises histrionics claiming that there's no one in charge, less than 24 hours later the one in charge pops up and says "hi, of course I can make a release" but also begins a discussion about passing on the torch to a new release manager. I find it very difficult, based on that link, to even begin to understand why one might think cairo is unmaintained.

But hey, that's all completely irrelevant. Dropping a complex binary dependency is not necessarily a bad thing, if you think you don't need it. Just don't blame it on "they have organizational problems". :)

...

Might I recommend making sure unittests pass on your latest release, even if you've rewritten the code in unreleased master? It's not exactly hard to hotfix this, either -- pytest.mark.xfail(condition=cairocffi.cairo_version() >= 11700, reason="tests not yet updated to check 1.17").

Do you expect weasyprint to work on cairo 1.17 and it's just a matter of unittests not being updated?

It should not take more effort to if/else the tests based on cairo version than it would to go straight to the new version only. I would generally consider it advisable to test your software against the latest release of critical dependencies just for future proofing and to catch problems early, and you had several years to do it -- so it's a bit disappointing to not see this done, regardless of reasons.

@eli-schwartz eli-schwartz changed the title Cannot figure out how to get tests to pass tests do not pass with latest cairo Jan 26, 2021
@liZe
Copy link
Member

liZe commented Jan 26, 2021

Tests don’t pass probably because you have Cairo 1.17.x. Tests only pass with Cairo 1.16.x.

Thank you for confirming this is a bug in WeasyPrint.

No problem!

As Cairo suffers from technical and organizational problems (see Cairo’s mailing list), we decided to write our own PDF generator. It takes some time, that’s why there’s no release yet without Cairo.

That's just an incredibly, incredibly weak argument. One person raises histrionics claiming that there's no one in charge, less than 24 hours later the one in charge pops up and says "hi, of course I can make a release" but also begins a discussion about passing on the torch to a new release manager. I find it very difficult, based on that link, to even begin to understand why one might think cairo is unmaintained.

But hey, that's all completely irrelevant. Dropping a complex binary dependency is not necessarily a bad thing, if you think you don't need it. Just don't blame it on "they have organizational problems". :)

We don’t want to use Cairo anymore for many reasons. I wrote that "Cairo suffers from technical and organizational problems" and gave an example, that’s all. I didn’t say that the organizational problems were the only reasons.

If you want to technical reasons (not the only ones):

  • Having multiple output formats makes Cairo really powerful, but also very complicated. Having one output format removes layers that are useless for us.
  • The available features for the output backends are often the features available for all formats, because it’s long and hard to have dedicated features for each format. Some PDF features have been added, but we would benefit from a library really dedicated to PDF generation.
  • Cairo is theoretically available for all platforms, but it’s not really packaged for Windows. As you said, dropping a complex binary is not necessarily a bad thing 😉.
  • Some of their technical choices cause problems that are hard (impossible?) to solve correctly. We don’t want nightmares like CAIRO_STATUS_TAG_ERROR: b'invalid tag name, attributes, or nesting' #742 anymore (just an example, I let you find other tickets).

And I definitely think and say that they have organizational problems.

  • The thread I mentioned follows another one two months earlier, complaining about the 1,5-year-old latest release. Nobody wants/can do the release in this thread.
  • Tests are broken, and that’s not because of the latest version of a dependency 😉. There are regressions in 1.17.4, and some are related to font rendering. Some failing tests in WeasyPrint probably fail because of that. And that’s not necessarily a bug in Cairo, just something that’s changed and that’s not documented.
  • According to Bryce, the person who released Cairo 1.17.2 and 1.17.4, Cairo 1.17.x are unstable releases.
  • Then why some Linux distributions and Homebrew distribute this unstable version? Because the latest stable version has been released more than two years ago and has a lot of bugs. And because the stable/unstable status is not really clear.
  • The Cairo team wants to release a new 1.16.x version. But what will happen on distributions where 1.17.x versions are marked as stable?

I really love the Cairo team, I really love the Cairo library, I have huge respect for what they do. This library is incredible. It’s just that it’s not adapted to WeasyPrint anymore, in our opinion. For technical reasons, for organizational reasons.

Might I recommend making sure unittests pass on your latest release, even if you've rewritten the code in unreleased master? It's not exactly hard to hotfix this, either -- pytest.mark.xfail(condition=cairocffi.cairo_version() >= 11700, reason="tests not yet updated to check 1.17").

Do you expect weasyprint to work on cairo 1.17 and it's just a matter of unittests not being updated?

Version 53 of WeasyPrint will not use Cairo anymore. We may want to spend time on the 52.x versions in the future, to make it compatible with new stable versions of Cairo, but that’s not sure at all.

Tests currently don’t pass because some things are broken. Adding xfails won’t fix WeasyPrint with Cairo 1.17.x versions, that’s not a way to make "weasyprint to work on cairo 1.17" (unfortunately 😄).

It should not take more effort to if/else the tests based on cairo version than it would to go straight to the new version only. I would generally consider it advisable to test your software against the latest release of critical dependencies just for future proofing and to catch problems early, and you had several years to do it -- so it's a bit disappointing to not see this done, regardless of reasons.

Cairo 1.17.4 is not a Cairo release. It’s just a "development snapshot". WeasyPrint 52.x is tested with "the latest release of critical dependencies", which is 1.16.0 for Cairo.

We prefer to spend our time on WeasyPrint’s next version, instead of supporting next versions of Cairo. We took some time to write a PDF generator allowing us to fix many bugs caused by Cairo and to add many features. You may agree, you may disagree. You may even be disappointed.

I was disappointed too. To see that ArchLinux and Homebrew, for example, decided to include a Cairo snapshot just as if it was a stable release. But, well, they do what they want after all, they don’t owe me anything 😉. It’s not Arch’s fault. It’s not Cairo’s fault. It’s just hard to maintain free software and people often do their best.

We’ll be happy and grateful to merge a pull request fixing WeasyPrint with Cairo 1.17.4 in the 52.x branch. It’s just not our priority right now.

@liZe liZe changed the title tests do not pass with latest cairo Tests do not pass with Cairo development snapshots Jan 26, 2021
@liZe liZe added the bug Existing features not working as expected label Jan 26, 2021
@FelixSchwarz
Copy link
Contributor

Just wanted to mention that we have the same problem in Fedora and I started to look into this issue but did not produce any meaningful artefact due to my lack of free time. I'll try to come up with a patch before the Fedora 34 cutoff date (otherwise we'd have to remove WeasyPrint).

If anyone else starts to work on this issue please leave a message in this ticket (or ping me directly) so to avoid duplicate work. My idea would be to build a minimal reproduction test case in Python (via cairocffi). Maybe that is already enough and we can figure out what needs to be changed. Otherwise I would try to create a minimal C program so the cairo developers could help out.

@FelixSchwarz
Copy link
Contributor

Btw: I did start to build a minimal reproduction example (though it seems like there is still a long road ahead of me). Current state is published at https://github.com/FelixSchwarz/cairo117-repro

Also I bisected the problem back to cairo commit ea932921:

commit ea9329215d3431ded51a71b724baf0edc25ad633/ea9329215d3431ded51a71b724baf0edc25ad633)
Author: Matthias Clasen <mclasen at redhat.com>
Date:   Sat Jul 28 12:25:47 2018 +0000

     image compositor: Support subpixel positioning

Reverting that commit on top of the current cairo master fixes the WeasyPrint problem for me.

@liZe
Copy link
Member

liZe commented Mar 16, 2021

@FelixSchwarz Thanks a lot for your hard work on this.

Could you try to use the weasyprint.otf font instead of Ahem? It’s almost the same font (with some advanced OpenType features), but metrics have been changed to please PANGO_SCALE and avoid rounding errors.

By the way, Cairo 1.17.4 also suffers from a bug that randomly breaks fonts embedded in PDF documents. The patch used to solve the issue has to be applied to your version of Cairo, or WeasyPrint will be hardly usable.

@FelixSchwarz
Copy link
Contributor

@liZe Thanks for the pointer. I'll try to get the patch included in Fedora's cairo.

Btw: Any estimate when the pydyf version will be ready? I'm trying to plan how much time I should spend beating cairo into shape... (Feel free to send me a direct email if you don't want to communicate this publicly yet)

@FelixSchwarz
Copy link
Contributor

sorry for the noise but I just wanted to mention that Fedora 34 will include the patch for cairo issue 449 so pinging us (me) about any underlying library issues is highly appreciated: https://bugzilla.redhat.com/show_bug.cgi?id=1939399

@liZe
Copy link
Member

liZe commented Mar 16, 2021

Btw: Any estimate when the pydyf version will be ready? I'm trying to plan how much time I should spend beating cairo into shape...

We hope to release a beta version in April, and to release a stable version when all the reported bugs are fixed (between June and September?)

@eli-schwartz
Copy link
Contributor Author

I have had the same patch backported to Arch Linux too:
https://git.archlinux.org/svntogit/packages.git/commit/trunk?h=packages/cairo&id=60d4e8e444676c7e070b5fb08eb1e317fa7baf96

@liZe
Copy link
Member

liZe commented Aug 17, 2021

We hope to release a beta version in April, and to release a stable version when all the reported bugs are fixed (between June and September?)

It’s now released 🚀!

@liZe liZe closed this as completed Aug 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Existing features not working as expected
Projects
None yet
Development

No branches or pull requests

4 participants