2 from info_translator
import InfoTranslator
4 class T(rst_test_utils
.TestCase
):
6 def given_input(self
, input):
7 super(T
, self
).given_input(input)
8 self
.visitor
= InfoTranslator(self
.document
)
9 self
.visitor
.section_level
= -1 #HACK: core.publish_* start at 0, but that makes these tests fail - maybe missing some attribute set on the new document?
10 self
.document
.walkabout(self
.visitor
)
15 def test_adds_info_header(self
):
16 self
.assertTrue(self
.visitor
.astext().startswith('\\input texinfo'))
23 self
.assertEqual(['@node Top', '@top Hello, world!'], self
.visitor
.body
)
25 def test_chapter(self
):
34 self
.assertEqual(['@node Top', '@top Title!', '@chapter Chapter 1'],
37 def test_section(self
):
49 self
.assertEqual(['@node Top', '@top Title!',
51 '@section Section 1'],
54 def test_subsection(self
):
69 self
.assertEqual(['@node Top', '@top Title!',
72 '@subsection Subsection 1'],
75 def test_section_layering(self
):
96 self
.assertEqual(['@node Top', '@top A Plan for the Moon',
97 '@chapter The Problem',
99 '@subsection Lunar mold',
101 '@chapter A Modest Solution'],
104 def test_beyond_subsections(self
):
129 self
.assertEqual(['@node Top', '@top Title!',
130 '@chapter Chapter 1',
131 '@section Section 1',
132 '@subsection Subsection 1',
133 '@subsection Something else',
134 '@subsection Subsection 2',
135 '@section Section 2'],
138 def test_comments_are_comments(self
):
142 self
.assertEqual(['@c hello-world:'], self
.visitor
.body
)
144 def test_paragraph_text_is_normal_text(self
):
146 Someone left the cake out in the rain.
147 I don't think that I can take it.
149 self
.assertEqual(["Someone left the cake out in the rain.\nI don't think that I can take it."], self
.visitor
.body
)
151 def test_two_paragraphs(self
):
153 MacArthur's park is melting in the dark.
155 Someone left the cake out in the rain.
156 I don't think that I can take it.
158 self
.assertEqual(["MacArthur's park is melting in the dark.",
159 "Someone left the cake out in the rain.\nI don't think that I can take it."], self
.visitor
.body
)
162 def test_single_bullet_list(self
):
166 self
.assertEqual(["@itemize @bullet",
170 "@end @itemize"], self
.visitor
.body
)
172 def test_three_bullet_list(self
):
178 self
.assertEqual(["@itemize @bullet",
188 "@end @itemize"], self
.visitor
.body
)
190 def test_quotation(self
):
192 Never precede any action with the words "Watch this!"
193 -- the first commandment of frisbeetarianism
196 self
.assertEqual(["@quotation",
197 '''Never precede any action with the words "Watch this!"
198 -- the first commandment of frisbeetarianism''',
199 "@end quotation"], self
.visitor
.body
)
201 def test_formatted_code(self
):
203 Frisbeetarianism is the belief that, when you die, your soul goes up
204 onto the roof and gets stuck.
206 Never precede any action with the words "Watch this!"
207 -- the first constant Law of Frisbee
210 '''Frisbeetarianism is the belief that, when you die, your soul goes up
211 onto the roof and gets stuck.''',
213 '''Never precede any action with the words "Watch this!"
214 -- the first constant Law of Frisbee''',
215 "@end quotation"], self
.visitor
.body
)
217 def test_literal_block(self
):
221 "Just the place for a Snark!" the Bellman cried,
222 As he landed his crew with care;
223 Supporting each man on the top of the tide
224 By a finger entwined in his hair.
227 self
.assertEqual(["THE LANDING:",
228 """"Just the place for a Snark!" the Bellman cried,
229 As he landed his crew with care;
230 Supporting each man on the top of the tide
231 By a finger entwined in his hair."""
232 ], self
.visitor
.body
)