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

WeasyPrint v57.0: failures in test_gradient.py #1746

Closed
FelixSchwarz opened this issue Oct 18, 2022 · 2 comments
Closed

WeasyPrint v57.0: failures in test_gradient.py #1746

FelixSchwarz opened this issue Oct 18, 2022 · 2 comments

Comments

@FelixSchwarz
Copy link
Contributor

I tried to update WeasyPrint to v57 in Fedora rawhide but there are two failures in test_gradient.py (build server results). Full build logs (including versions) via koji but I extracted the pytest output so maybe you can see the problem quicker that way:

=================================== FAILURES ===================================
___________________________ test_linear_gradients_5 ____________________________
assert_pixels = <function assert_pixels.<locals>.<lambda> at 0x7f4f2333cd60>
    @assert_no_logs
    def test_linear_gradients_5(assert_pixels):
>       assert_pixels('''
            rBrrrBrrrB
            rBrrrBrrrB
            rBrrrBrrrB
            rBrrrBrrrB
            rBrrrBrrrB
        ''', '''
          <style>@page { size: 10px 5px; background: repeating-linear-gradient(
          to right, blue 50%, blue 60%, red 60%, red 90%
        )''')
/builddir/build/BUILD/weasyprint-57.0/tests/draw/test_gradient.py:68: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/builddir/build/BUILD/weasyprint-57.0/tests/conftest.py:98: in <lambda>
    return lambda *args, **kwargs: draw.assert_pixels(
/builddir/build/BUILD/weasyprint-57.0/tests/draw/__init__.py:55: in assert_pixels
    assert_pixels_equal(name, width, height, pixels, expected_pixels)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
name = 'linear_gradients_5', width = 10, height = 5
raw = <ImagingCore object at 0x7f4f24552db0>
expected_raw = [(255, 0, 0), (0, 0, 255), (255, 0, 0), (255, 0, 0), (255, 0, 0), (0, 0, 255), ...]
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
            pixels = zip_longest(raw, expected_raw, fillvalue=(-1, -1, -1))
            for i, (value, expected) in enumerate(pixels):
                if expected is None:
                    continue
                if any(abs(value - expected) > tolerance
                       for value, expected in zip(value, expected)):
                    actual_height = len(raw) // width
                    write_png(name, raw, width, actual_height)
                    expected_raw = [
                        pixel or (255, 255, 255) for pixel in expected_raw]
                    write_png(f'{name}.expected', expected_raw, width, height)
                    x = i % width
                    y = i // width
>                   assert 0, (
                        f'Pixel ({x}, {y}) in {name}: '
                        f'expected rgba{expected}, got rgba{value}')
E                   AssertionError: Pixel (0, 0) in linear_gradients_5: expected rgba(255, 0, 0), got rgba(255, 255, 255)
/builddir/build/BUILD/weasyprint-57.0/tests/draw/__init__.py:104: AssertionError
------------------------------ Captured log call -------------------------------
...
___________________________ test_linear_gradients_12 ___________________________
assert_pixels = <function assert_pixels.<locals>.<lambda> at 0x7f4f21f2b060>
    @assert_no_logs
    def test_linear_gradients_12(assert_pixels):
>       assert_pixels('''
            BBBBBBBBB
            BBBBBBBBB
            BBBBBBBBB
            BBBBBBBBB
            BBBBBBBBB
        ''', '''<style>@page { size: 9px 5px; background:
          repeating-linear-gradient(to right, red 3px, blue 3px, blue 4px, red 4px
        )''')
/builddir/build/BUILD/weasyprint-57.0/tests/draw/test_gradient.py:159: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/builddir/build/BUILD/weasyprint-57.0/tests/conftest.py:98: in <lambda>
    return lambda *args, **kwargs: draw.assert_pixels(
/builddir/build/BUILD/weasyprint-57.0/tests/draw/__init__.py:55: in assert_pixels
    assert_pixels_equal(name, width, height, pixels, expected_pixels)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
name = 'linear_gradients_12', width = 9, height = 5
raw = <ImagingCore object at 0x7f4f23bbb550>
expected_raw = [(0, 0, 255), (0, 0, 255), (0, 0, 255), (0, 0, 255), (0, 0, 255), (0, 0, 255), ...]
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
            pixels = zip_longest(raw, expected_raw, fillvalue=(-1, -1, -1))
            for i, (value, expected) in enumerate(pixels):
                if expected is None:
                    continue
                if any(abs(value - expected) > tolerance
                       for value, expected in zip(value, expected)):
                    actual_height = len(raw) // width
                    write_png(name, raw, width, actual_height)
                    expected_raw = [
                        pixel or (255, 255, 255) for pixel in expected_raw]
                    write_png(f'{name}.expected', expected_raw, width, height)
                    x = i % width
                    y = i // width
>                   assert 0, (
                        f'Pixel ({x}, {y}) in {name}: '
                        f'expected rgba{expected}, got rgba{value}')
E                   AssertionError: Pixel (0, 0) in linear_gradients_12: expected rgba(0, 0, 255), got rgba(255, 255, 255)
/builddir/build/BUILD/weasyprint-57.0/tests/draw/__init__.py:104: AssertionError
------------------------------ Captured log call -------------------------------
...
=============================== warnings summary ===============================
...
=========================== short test summary info ============================
FAILED tests/draw/test_gradient.py::test_linear_gradients_5 - AssertionError:...
FAILED tests/draw/test_gradient.py::test_linear_gradients_12 - AssertionError...
====== 2 failed, 1870 passed, 41 xfailed, 8 warnings in 90.75s (0:01:30) =======

I guess next thing is that you are asking me for the PDF generated in the test as you did previously? I can do that but not today.

@liZe
Copy link
Member

liZe commented Oct 18, 2022

I think that these bugs are caused by Ghostscript’s bug 705225. They appear only with Ghostscript 9.56, but not with 9.55 or 10.0.

@FelixSchwarz
Copy link
Contributor Author

Ah, I see. As you provided a very specific reference, Fedora has now a PR to cherry-pick that patch to its ghostscript package until ghostscript 10.0 is added Fedora.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants