mirror of
https://github.com/Kozea/WeasyPrint.git
synced 2024-10-05 00:21:15 +03:00
61 lines
1.5 KiB
Python
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
|
|
])
|