Use transforms in info_translator tests so we can test title and
[rst2info.git] / texinfo / test_info_writer.py
blobc95a5e2122b49645e746c45809933bc7e96012ad
1 import unittest
2 from info_writer import InfoWriter
4 class T(unittest.TestCase):
6 def given_input(self, input):
7 from docutils.core import publish_string
8 self.output = publish_string(input, writer_name='texinfo')
10 def setUp(self):
11 self.writer = InfoWriter()
13 def test_writer_supports_texinfo(self):
14 self.assertTrue(self.writer.supports('texinfo'))
16 def test_translate_alice(self):
17 self.given_input("""
18 ********************************
19 Alice In Wonderland
20 ********************************
22 ================================
23 Foo
24 ================================
26 CHAPTER I. Down the Rabbit-Hole
27 ===============================
29 Alice was beginning to get very tired of sitting by her sister on the
30 bank, and of having nothing to do: once or twice she had peeped into the
31 book her sister was reading, but it had no pictures or conversations in
32 it, 'and what is the use of a book,' thought Alice 'without pictures or
33 conversation?'
34 """)
35 self.assertEqual(self.output,
36 """\\input texinfo @c -*-texinfo-*-
38 @node Top
39 @top Alice In Wonderland
40 @majorheading Foo
41 @chapter CHAPTER I. Down the Rabbit-Hole
42 Alice was beginning to get very tired of sitting by her sister on the
43 bank, and of having nothing to do: once or twice she had peeped into the
44 book her sister was reading, but it had no pictures or conversations in
45 it, 'and what is the use of a book,' thought Alice 'without pictures or
46 conversation?'
47 """)
49 def test_translate_frisbeetarianism(self):
50 self.given_input("""
51 ================
52 Frisbeetarianism
53 ================
55 Frisbeetarianism is the belief that, when you die, your soul goes up
56 onto the roof and gets stuck.
58 Never precede any action with the words "Watch this!"
59 -- the first constant Law of Frisbee
60 """)
61 self.assertEqual(self.output,
62 """\\input texinfo @c -*-texinfo-*-
64 @node Top
65 @top Frisbeetarianism
66 Frisbeetarianism is the belief that, when you die, your soul goes up
67 onto the roof and gets stuck.
68 @quotation
69 Never precede any action with the words "Watch this!"
70 -- the first constant Law of Frisbee
71 @end quotation
72 """)
74 if __name__=='__main__':
75 import unittest
76 unittest.main()