1
1
mirror of https://github.com/Kozea/WeasyPrint.git synced 2024-10-04 07:57:52 +03:00
WeasyPrint/weasyprint/tests/test_acid2.py
2020-05-16 00:25:11 +02:00

35 lines
1.1 KiB
Python

"""
weasyprint.tests.test_draw.test_acid2
-------------------------------------
Check the famous Acid2 test.
"""
from .. import HTML
from .test_draw import assert_pixels_equal, image_to_pixels
from .testing_utils import assert_no_logs, capture_logs, resource_filename
@assert_no_logs
def test_acid2():
def render(filename):
return HTML(resource_filename(filename)).render()
with capture_logs():
# This is a copy of http://www.webstandards.org/files/acid2/test.html
document = render('acid2-test.html')
intro_page, test_page = document.pages
# Ignore the intro page: it is not in the reference
test_image, width, height = document.copy(
[test_page]).write_image_surface()
# This is a copy of http://www.webstandards.org/files/acid2/reference.html
ref_image, ref_width, ref_height = render(
'acid2-reference.html').write_image_surface()
assert (width, height) == (ref_width, ref_height)
assert_pixels_equal(
'acid2', width, height, image_to_pixels(test_image, width, height),
image_to_pixels(ref_image, width, height), tolerance=2)