removed obsolete issues (many of them fixed with AE)
[docutils.git] / sandbox / dkuhlman / docutils / test / test_writers / test_python_latex.py
blob7aa5528ce5d29ec15ec07e67fb0b502eafbf029a
1 #! /usr/bin/env python
3 # Author: Dave Kuhlman
4 # Contact: dkuhlman@rexx.com
5 # Revision: $Revision$
6 # Date: $Date$
7 # Copyright: This module has been placed in the public domain.
9 """
10 Tests for python_latex writer.
11 """
13 from __init__ import DocutilsTestSupport
15 def suite():
16 s = DocutilsTestSupport.PythonLatexPublishTestSuite()
17 s.generateTests(totest)
18 return s
21 rest_head = """\
23 ==========================
24 Unit Test for Python LaTeX
25 ==========================
28 :author: Dave Kuhlman
29 :address: dkuhlman@rexx.com \\\\
30 http://www.rexx.com/~dkuhlman
32 :revision: 1.0a
33 :date: Aug. 4, 2003
35 :copyright: Copyright (c) 2003 Dave Kuhlman.
36 [an Open Source copyright]
38 :abstract: This document contains input for unit tests for the
39 Python LaTeX writer for Docutils.
41 .. sectnum:: :depth: 2
43 .. contents::
46 """
48 latex_head = r"""\documentclass{howto}
50 % generator -- Docutils: http://docutils.sourceforge.net/
51 % writer -- documenting_python
52 % generated on -- Wed Aug 13 16:08:04 2003
54 \usepackage{html}
55 \title{Unit Test for Python LaTeX}
56 \release{1.0a}
57 \date{Aug. 4, 2003}
58 \author{Dave Kuhlman}
59 \authoraddress{dkuhlman@rexx.com \
60 http://www.rexx.com/\~{}dkuhlman}
61 \begin{document}
62 \maketitle
63 \ifhtml
64 \chapter*{Front Matter\label{front}}
65 \fi
67 Copyright (c) 2003 Dave Kuhlman.
68 [an Open Source copyright]
69 \begin{abstract}
70 \noindent
72 This document contains input for unit tests for the
73 Python LaTeX writer for Docutils.
74 \end{abstract}
75 \tableofcontents
77 """
79 totest = {}
81 totest['section_headers'] = [
82 # input
83 [rest_head + r"""
84 Section #1
85 ==========
87 Content for section #1.
89 Subsection #1-1
90 ---------------
92 Content for sub-section #1-1.
94 Subsection #1-2
95 ---------------
97 Content for sub-section #1-2.
99 Section #2
100 ==========
102 Content for section #2.
104 """,
106 # expected output
107 latex_head + r"""
108 %___________________________________________________________________________
110 \section{1   Section {\#}1\label{section-1}}
112 Content for section {\#}1.
115 %___________________________________________________________________________
117 \subsection{1.1   Subsection {\#}1-1\label{subsection-1-1}}
119 Content for sub-section {\#}1-1.
122 %___________________________________________________________________________
124 \subsection{1.2   Subsection {\#}1-2\label{subsection-1-2}}
126 Content for sub-section {\#}1-2.
129 %___________________________________________________________________________
131 \section{2   Section {\#}2\label{section-2}}
133 Content for section {\#}2.
135 \end{document}
136 """],
139 # ==============================================================
141 totest['enumerated_lists'] = [
142 # input
143 [rest_head + r"""
144 Enumerated List Test Section
145 ============================
147 Here is an enumerated list:
149 1. This is an item.
151 2. This is an item.
153 3. This is an item.
155 """,
157 # expected output
158 latex_head + r"""
159 %___________________________________________________________________________
161 \section{1   Enumerated List Test Section\label{enumerated-list-test-section}}
163 Here is an enumerated list:
164 \begin{enumerate}
165 \item
166 This is an item.
168 \item
169 This is an item.
171 \item
172 This is an item.
174 \end{enumerate}
176 \end{document}
177 """],
181 # ==============================================================
183 totest['itemized_lists'] = [
184 # input
185 [rest_head + r"""
186 Itemized List Test Section
187 ==========================
189 Here is an itemized list:
191 - This is an item.
193 - This is an item.
195 - This is an item.
197 """,
199 # expected output
200 latex_head + r"""
201 %___________________________________________________________________________
203 \section{1   Itemized List Test Section\label{itemized-list-test-section}}
205 Here is an itemized list:
206 \begin{itemize}
207 \item
208 This is an item.
210 \item
211 This is an item.
213 \item
214 This is an item.
216 \end{itemize}
218 \end{document}
219 """],
222 # ==============================================================
224 totest['links'] = [
225 # input
226 [rest_head + r"""
227 Section #1
228 ==========
230 Content for section #1.
232 Subsection #1-1
233 ---------------
235 Content for sub-section #1-1.
237 Subsection #1-2
238 ---------------
240 Content for sub-section #1-2.
242 Section #2
243 ==========
245 Content for section #2.
247 Links Test Section
248 ==================
250 Here is a link to the section which is the target of this
251 internal link `Subsection #1-1`_.
253 """,
255 # expected output
256 latex_head + r"""
257 %___________________________________________________________________________
259 \section{1   Section {\#}1\label{section-1}}
261 Content for section {\#}1.
264 %___________________________________________________________________________
266 \subsection{1.1   Subsection {\#}1-1\label{subsection-1-1}}
268 Content for sub-section {\#}1-1.
271 %___________________________________________________________________________
273 \subsection{1.2   Subsection {\#}1-2\label{subsection-1-2}}
275 Content for sub-section {\#}1-2.
278 %___________________________________________________________________________
280 \section{2   Section {\#}2\label{section-2}}
282 Content for section {\#}2.
285 %___________________________________________________________________________
287 \section{3   Links Test Section\label{links-test-section}}
289 Here is a link to the section which is the target of this
290 internal link \ref{subsection-1-1}.
292 \end{document}
293 """],
296 # ==============================================================
298 totest['seealso'] = [
299 # input
300 [rest_head + r"""
301 See Also
302 ========
304 `Docutils: Python Documentation Utilities`_
306 .. _`Docutils: Python Documentation Utilities`:
307 http://docutils.sourceforge.net/
309 """,
311 # expected output
312 latex_head + r"""
313 %___________________________________________________________________________
315 \section{1   See Also\label{see-also}}
317 \ulink{Docutils: Python Documentation Utilities}{http://docutils.sourceforge.net/}
319 \end{document}
320 """],
324 # ==============================================================
326 totest['emphasis'] = [
327 # input
328 [rest_head + r"""
329 Section #1
330 ==========
332 This section contains *some emphaized text*.
334 It **also has some bold text**.
336 And ``this is sample text``, or, as it is known in reStructured
337 Text, an in-line literal.
339 """,
341 # expected output
342 latex_head + r"""
343 %___________________________________________________________________________
345 \section{1   Section {\#}1\label{section-1}}
347 This section contains \emph{some emphaized text}.
349 It \strong{also has some bold text}.
351 And \samp{this is sample text}, or, as it is known in reStructured
352 Text, an in-line literal.
354 \end{document}
355 """],
359 # ==============================================================
361 totest['blockquote'] = [
362 # input
363 [rest_head + r"""
364 Block Quote Test
365 ================
367 This section contains a paragraph which is followed by a block
368 quote. The block quote is a simple paragraph that is indented.
370 This is the block quoted paragraph. It has several sentences.
371 These sentences have empty content because they are only a
372 test. This is a test. This is a test. This is a test. This
373 is a test. This is a test. This is a test.
376 Python Iteractive Session Test
377 ==============================
379 This section has a Python interactive session. It is a test.
380 Here is the example session.
382 >>> import sys
383 >>> print sys.version
384 2.3 (#1, Jul 31 2003, 15:26:15)
385 [GCC 3.2.3 20030415 (Debian prerelease)]
386 >>> a = [11,22,33]
387 >>> for x in a:
388 ... print x
395 Literal Block Test
396 ==================
398 This section has a literal block. In Python LaTeX it will be
399 formatted in a verbatim environment::
401 def remove_lines(self, inStr, targetList):
402 inLines = inStr.splitlines()
403 outLines = []
404 for line in inLines:
405 remove = False
406 for target in targetList:
407 if line.find(target) > -1:
408 remove = True
409 if not remove:
410 outLines.append(line)
411 outStr = '\n'.join(outLines)
412 return outStr
414 """,
416 # expected output
417 latex_head + r"""
418 %___________________________________________________________________________
420 \section{1   Block Quote Test\label{block-quote-test}}
422 This section contains a paragraph which is followed by a block
423 quote. The block quote is a simple paragraph that is indented.
424 \begin{quote}
426 This is the block quoted paragraph. It has several sentences.
427 These sentences have empty content because they are only a
428 test. This is a test. This is a test. This is a test. This
429 is a test. This is a test. This is a test.
430 \end{quote}
433 %___________________________________________________________________________
435 \section{2   Python Iteractive Session Test\label{python-iteractive-session-test}}
437 This section has a Python interactive session. It is a test.
438 Here is the example session.
439 \begin{verbatim}
440 >>> import sys
441 >>> print sys.version
442 2.3 (#1, Jul 31 2003, 15:26:15)
443 [GCC 3.2.3 20030415 (Debian prerelease)]
444 >>> a = [11,22,33]
445 >>> for x in a:
446 ... print x
451 \end{verbatim}
454 %___________________________________________________________________________
456 \section{3   Literal Block Test\label{literal-block-test}}
458 This section has a literal block. In Python LaTeX it will be
459 formatted in a verbatim environment:
461 \begin{verbatim}
462 def remove_lines(self, inStr, targetList):
463 inLines = inStr.splitlines()
464 outLines = []
465 for line in inLines:
466 remove = False
467 for target in targetList:
468 if line.find(target) > -1:
469 remove = True
470 if not remove:
471 outLines.append(line)
472 outStr = '\n'.join(outLines)
473 return outStr
474 \end{verbatim}
476 \end{document}
477 """],
481 # ==============================================================
483 if __name__ == '__main__':
484 import unittest
485 unittest.main(defaultTest='suite')