File: test_list.py

package info (click to toggle)
weasyprint 67.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,896 kB
  • sloc: python: 61,025; makefile: 12
file content (74 lines) | stat: -rw-r--r-- 1,974 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
"""Test how lists are drawn."""

import pytest

from ..testing_utils import SANS_FONTS, assert_no_logs


@assert_no_logs
@pytest.mark.parametrize(('position', 'pixels'), [
    ('outside',
     #  ++++++++++++++      ++++  <li> horizontal margins: 7px 2px
     #                ######      <li> width: 12 - 7 - 2 = 3px
     #              --            list marker margin: 0.5em = 2px
     #      ********              list marker image is 4px wide
     '''
        ____________
        ____________
        ___rBBB_____
        ___BBBB_____
        ___BBBB_____
        ___BBBB_____
        ____________
        ____________
        ____________
        ____________
     '''),
    ('inside',
     #  ++++++++++++++      ++++  <li> horizontal margins: 7px 2px
     #                ######      <li> width: 12 - 7 - 2 = 3px
     #                ********    list marker image is 4px wide: overflow
     '''
        ____________
        ____________
        _______rBBB_
        _______BBBB_
        _______BBBB_
        _______BBBB_
        ____________
        ____________
        ____________
        ____________
     ''')
])
def test_list_style_image(assert_pixels, position, pixels):
    assert_pixels(pixels, '''
      <style>
        @page { size: 12px 10px }
        body { margin: 0; font-family: %s }
        ul { margin: 2px 2px 0 7px; list-style: url(pattern.png) %s;
             font-size: 2px }
      </style>
      <ul><li></li></ul>''' % (SANS_FONTS, position))


@assert_no_logs
def test_list_style_image_none(assert_pixels):
    assert_pixels('''
        __________
        __________
        __________
        __________
        __________
        __________
        __________
        __________
        __________
        __________
    ''', '''
      <style>
        @page { size: 10px }
        body { margin: 0; font-family: %s }
        ul { margin: 0 0 0 5px; list-style: none; font-size: 2px; }
      </style>
      <ul><li>''' % (SANS_FONTS,))