Debian Codegraph @

tests/test_extensions/test_blocks/test_definition.py

raw
1 """Test cases for Blocks (define)."""
2 from ... import util
3
4
5 class TestBlocksDefinition(util.MdCase):
6 """Test Blocks admonitions cases."""
7
8 extension = ['pymdownx.blocks.definition', 'pymdownx.blocks.html']
9
10 def test_def(self):
11 """Test definition."""
12
13 self.check_markdown(
14 R'''
15 /// define
16 Apple
17
18 - Pomaceous fruit of plants of the genus Malus in
19 the family Rosaceae.
20
21 ///
22 ''',
23 R'''
24 <dl>
25 <dt>Apple</dt>
26 <dd>Pomaceous fruit of plants of the genus Malus in
27 the family Rosaceae.</dd>
28 </dl>
29 ''',
30 True
31 )
32
33 def test_multi_def(self):
34 """Test multiple definitions."""
35
36 self.check_markdown(
37 R'''
38 /// define
39 Apple
40
41 - Pomaceous fruit of plants of the genus Malus in
42 the family Rosaceae.
43
44 Orange
45
46 - The fruit of an evergreen tree of the genus Citrus.
47
48 ///
49 ''',
50 R'''
51 <dl>
52 <dt>Apple</dt>
53 <dd>Pomaceous fruit of plants of the genus Malus in
54 the family Rosaceae.</dd>
55 <dt>Orange</dt>
56 <dd>The fruit of an evergreen tree of the genus Citrus.</dd>
57 </dl>
58 ''',
59 True
60 )
61
62 def test_multi_term(self):
63 """Test definitions with multiple terms."""
64
65 self.check_markdown(
66 R'''
67 /// define
68 Term 1
69
70 Term 2
71
72 - Definition a
73
74 Term 3
75
76 - Definition b
77 ///
78 ''',
79 r'''
80 <dl>
81 <dt>Term 1</dt>
82 <dt>Term 2</dt>
83 <dd>Definition a</dd>
84 <dt>Term 3</dt>
85 <dd>Definition b</dd>
86 </dl>
87 ''',
88 True
89 )
90
91 def test_handling_of_dt_dd(self):
92 """Test that we ignore `dt` and `dd` tags."""
93
94 self.check_markdown(
95 R'''
96 /// define
97 //// html | dt
98 term
99 ////
100
101 //// html | dd
102 Some description.
103 ////
104 ///
105 ''',
106 R'''
107 <dl>
108 <dt>term</dt>
109 <dd>Some description.</dd>
110 </dl>
111 ''',
112 True
113 )
114
115 def test_non_paragraph_block(self):
116 """Test that we sanely handle a non-paragraph term."""
117
118 self.check_markdown(
119 R'''
120 /// define
121
122 > A non non-paragraph term
123
124 - description
125
126 ///
127 ''',
128 R'''
129 <dl>
130 <dt>
131 <blockquote>
132 <p>A non non-paragraph term</p>
133 </blockquote>
134 </dt>
135 <dd>description</dd>
136 </dl>
137 ''',
138 True
139 )