1
1
mirror of https://github.com/Kozea/WeasyPrint.git synced 2024-10-04 16:07:57 +03:00
WeasyPrint/tests/test_draw/test_opacity.py
Guillaume Ayoub 4f82a4a34e Packaging!
Related to #1247, #1232.
2020-12-06 20:19:59 +01:00

61 lines
1.5 KiB
Python

"""
weasyprint.tests.test_draw.test_opacity
---------------------------------------
Test opacity.
"""
from ..testing_utils import assert_no_logs
from . import assert_same_rendering
opacity_source = '''
<style>
@page { size: 60px 60px }
body { margin: 0; background: #fff }
div { background: #000; width: 20px; height: 20px }
</style>
%s'''
@assert_no_logs
def test_opacity_1():
assert_same_rendering(60, 60, [
('opacity_0_reference', opacity_source % '''
<div></div>
'''),
('opacity_0', opacity_source % '''
<div></div>
<div style="opacity: 0"></div>
'''),
])
@assert_no_logs
def test_opacity_2():
assert_same_rendering(60, 60, [
('opacity_color_reference', opacity_source % '''
<div style="background: rgb(102, 102, 102)"></div>
'''),
('opacity_color', opacity_source % '''
<div style="opacity: 0.6"></div>
'''),
])
@assert_no_logs
def test_opacity_3():
assert_same_rendering(60, 60, [
('opacity_multiplied_reference', opacity_source % '''
<div style="background: rgb(102, 102, 102)"></div>
'''),
('opacity_multiplied', opacity_source % '''
<div style="opacity: 0.6"></div>
'''),
('opacity_multiplied_2', opacity_source % '''
<div style="background: none; opacity: 0.666666">
<div style="opacity: 0.9"></div>
</div>
'''), # 0.9 * 0.666666 == 0.6
])