Merge branch 'master' into def-lists
[rst2info.git] / texinfo / test_info_writer.py
blob8a5103c91987a2814d3ebe251c1c6fdab320fea5
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 settings_overrides={} #{'debug': True}
9 self.output = publish_string(input, writer_name='texinfo', settings_overrides=settings_overrides)
11 def setUp(self):
12 self.writer = InfoWriter()
14 def test_writer_supports_texinfo(self):
15 self.assertTrue(self.writer.supports('texinfo'))
17 def test_translate_alice(self):
18 self.given_input("""
19 ********************************
20 Alice In Wonderland
21 ********************************
23 ================================
24 Foo
25 ================================
27 CHAPTER I. Down the Rabbit-Hole
28 ===============================
30 Alice was beginning to get very tired of sitting by her sister on the
31 bank, and of having nothing to do: once or twice she had peeped into the
32 book her sister was reading, but it had no pictures or conversations in
33 it, 'and what is the use of a book,' thought Alice 'without pictures or
34 conversation?'
35 """)
36 self.assertEqual(self.output,
37 """\\input texinfo @c -*-texinfo-*-
39 @node Top
40 @top Alice In Wonderland
41 @majorheading Foo
42 @chapter CHAPTER I. Down the Rabbit-Hole
43 Alice was beginning to get very tired of sitting by her sister on the
44 bank, and of having nothing to do: once or twice she had peeped into the
45 book her sister was reading, but it had no pictures or conversations in
46 it, 'and what is the use of a book,' thought Alice 'without pictures or
47 conversation?'
49 """)
51 def test_translate_frisbeetarianism(self):
52 self.given_input("""
53 ================
54 Frisbeetarianism
55 ================
57 Frisbeetarianism is the belief that, when you die, your soul goes up
58 onto the roof and gets stuck.
60 Keep in mind always the four constant Laws of Frisbee:
62 (1) The most powerful force in the world is that of a disc
63 straining to land under a car, just out of reach (this
64 force is technically termed "car suck").
65 (2) Never precede any maneuver by a comment more predictive
66 than "Watch this!"
67 (3) The probability of a Frisbee hitting something is directly
68 proportional to the cost of hitting it. For instance, a
69 Frisbee will always head directly towards a policeman or
70 a little old lady rather than the beat up Chevy.
71 (4) Your best throw happens when no one is watching; when the
72 cute girl you've been trying to impress is watching, the
73 Frisbee will invariably bounce out of your hand or hit you
74 in the head and knock you silly.
76 """)
77 self.assertEqual(self.output,
78 """\\input texinfo @c -*-texinfo-*-
80 @node Top
81 @top Frisbeetarianism
82 Frisbeetarianism is the belief that, when you die, your soul goes up
83 onto the roof and gets stuck.
85 Keep in mind always the four constant Laws of Frisbee:
87 @quotation
88 @enumerate 1
89 @item
90 The most powerful force in the world is that of a disc
91 straining to land under a car, just out of reach (this
92 force is technically termed "car suck").
94 @item
95 Never precede any maneuver by a comment more predictive
96 than "Watch this!"
98 @item
99 The probability of a Frisbee hitting something is directly
100 proportional to the cost of hitting it. For instance, a
101 Frisbee will always head directly towards a policeman or
102 a little old lady rather than the beat up Chevy.
104 @item
105 Your best throw happens when no one is watching; when the
106 cute girl you've been trying to impress is watching, the
107 Frisbee will invariably bounce out of your hand or hit you
108 in the head and knock you silly.
110 @end enumerate
112 @end quotation
114 """)
116 if __name__=='__main__':
117 import unittest
118 unittest.main()