diff options
Diffstat (limited to 'test/test_writers')
| -rw-r--r-- | test/test_writers/__init__.py | 14 | ||||
| -rwxr-xr-x | test/test_writers/test_docutils_xml.py | 86 | ||||
| -rwxr-xr-x | test/test_writers/test_html4css1.py | 373 | ||||
| -rwxr-xr-x | test/test_writers/test_html4css1_misc.py | 36 | ||||
| -rwxr-xr-x | test/test_writers/test_latex2e.py | 377 | ||||
| -rwxr-xr-x | test/test_writers/test_null.py | 31 | ||||
| -rwxr-xr-x | test/test_writers/test_pseudoxml.py | 54 |
7 files changed, 971 insertions, 0 deletions
diff --git a/test/test_writers/__init__.py b/test/test_writers/__init__.py new file mode 100644 index 000000000..46fc50e06 --- /dev/null +++ b/test/test_writers/__init__.py @@ -0,0 +1,14 @@ +import os +import os.path +import sys + +sys.path.insert(0, os.path.abspath(os.path.dirname(__file__))) +prev = '' +while sys.path[0] != prev: + try: + import DocutilsTestSupport + break + except ImportError: + prev = sys.path[0] + sys.path[0] = os.path.dirname(prev) +sys.path.pop(0) diff --git a/test/test_writers/test_docutils_xml.py b/test/test_writers/test_docutils_xml.py new file mode 100755 index 000000000..c51d71379 --- /dev/null +++ b/test/test_writers/test_docutils_xml.py @@ -0,0 +1,86 @@ +#!/usr/bin/env python + +# Author: Felix Wiemann +# Contact: Felix_Wiemann@ososo.de +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. + +""" +Test for docutils XML writer. +""" + +from __init__ import DocutilsTestSupport + +import docutils +import docutils.core + + +class DocutilsXMLTestCase(DocutilsTestSupport.StandardTestCase): + + input = """\ +Test + +---------- + +Test. \xc3\xa4\xc3\xb6\xc3\xbc\xe2\x82\xac""" + xmldecl = '<?xml version="1.0" encoding="iso-8859-1"?>\n' + doctypedecl = '<!DOCTYPE document PUBLIC "+//IDN docutils.sourceforge.net//DTD Docutils Generic//EN//XML" "http://docutils.sourceforge.net/docs/ref/docutils.dtd">\n' + generatedby = '<!-- Generated by Docutils %s -->\n' % docutils.__version__ + bodynormal = '<document source="<string>"><paragraph>Test</paragraph><transition/><paragraph>Test. \xe4\xf6\xfc€</paragraph></document>' + bodynewlines = """\ +<document source="<string>"> +<paragraph> +Test +</paragraph> +<transition/> +<paragraph> +Test. \xe4\xf6\xfc€ +</paragraph> +</document> +""" + bodyindents = """\ +<document source="<string>"> + <paragraph> + Test + </paragraph> + <transition/> + <paragraph> + Test. \xe4\xf6\xfc€ + </paragraph> +</document> +""" + + def test_publish(self): + settings = {'input_encoding': 'utf8', + 'output_encoding': 'iso-8859-1', + '_disable_config': 1} + for settings['newlines'] in 0, 1: + for settings['indents'] in 0, 1: + for settings['xml_declaration'] in 0, 1: + for settings['doctype_declaration'] in 0, 1: + + expected = '' + if settings['xml_declaration']: + expected += self.xmldecl + if settings['doctype_declaration']: + expected += self.doctypedecl + expected += self.generatedby + if settings['indents']: + expected += self.bodyindents + elif settings['newlines']: + expected += self.bodynewlines + else: + expected += self.bodynormal + + self.assertEqual(docutils.core.publish_string + (source=self.input, + reader_name='standalone', + writer_name='docutils_xml', + settings_overrides=settings), + expected) + + +if __name__ == '__main__': + import unittest + unittest.main() diff --git a/test/test_writers/test_html4css1.py b/test/test_writers/test_html4css1.py new file mode 100755 index 000000000..7d87ee324 --- /dev/null +++ b/test/test_writers/test_html4css1.py @@ -0,0 +1,373 @@ +#! /usr/bin/env python + +# Author: reggie dugard +# Contact: reggie@users.sourceforge.net +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. + +""" +Test for fragment code in HTML writer. + +Note: the 'body' and 'whole' entries have been removed from the parts +dictionaries (redundant), along with 'meta' and 'stylesheet' entries with +standard values, and any entries with empty values. +""" + +from __init__ import DocutilsTestSupport +from docutils import core + +def suite(): + s = DocutilsTestSupport.HtmlPublishPartsTestSuite() + s.generateTests(totest) + return s + + +totest = {} + +totest['Title promotion'] = ({'stylesheet_path': '', + 'embed_stylesheet': 0}, [ +["""\ +Simple String +""", +"""\ +{'fragment': '''<p>Simple String</p>\\n''', + 'html_body': '''<div class="document"> +<p>Simple String</p> +</div>\\n''', + 'html_head': '''...<title></title>\\n'''} +"""], +["""\ +Simple String with *markup* +""", +"""\ +{'fragment': '''<p>Simple String with <em>markup</em></p>\\n''', + 'html_body': '''<div class="document"> +<p>Simple String with <em>markup</em></p> +</div>\\n''', + 'html_head': '''...<title></title>\\n'''} +"""], +["""\ +Simple String with an even simpler ``inline literal`` +""", +"""\ +{'fragment': '''<p>Simple String with an even simpler <tt class="docutils literal"><span class="pre">inline</span> <span class="pre">literal</span></tt></p>\\n''', + 'html_body': '''<div class="document"> +<p>Simple String with an even simpler <tt class="docutils literal"><span class="pre">inline</span> <span class="pre">literal</span></tt></p> +</div>\\n''', + 'html_head': '''...<title></title>\\n'''} +"""], +["""\ +A simple `anonymous reference`__ + +__ http://www.test.com/test_url +""", +"""\ +{'fragment': '''<p>A simple <a class="reference" href="http://www.test.com/test_url">anonymous reference</a></p>\\n''', + 'html_body': '''<div class="document"> +<p>A simple <a class="reference" href="http://www.test.com/test_url">anonymous reference</a></p> +</div>\\n''', + 'html_head': '''...<title></title>\\n'''} +"""], +["""\ +One paragraph. + +Two paragraphs. +""", +"""\ +{'fragment': '''<p>One paragraph.</p> +<p>Two paragraphs.</p>\\n''', + 'html_body': '''<div class="document"> +<p>One paragraph.</p> +<p>Two paragraphs.</p> +</div>\\n''', + 'html_head': '''...<title></title>\\n'''} +"""], +["""\ +A simple `named reference`_ with stuff in between the +reference and the target. + +.. _`named reference`: http://www.test.com/test_url +""", +"""\ +{'fragment': '''<p>A simple <a class="reference" href="http://www.test.com/test_url">named reference</a> with stuff in between the +reference and the target.</p>\\n''', + 'html_body': '''<div class="document"> +<p>A simple <a class="reference" href="http://www.test.com/test_url">named reference</a> with stuff in between the +reference and the target.</p> +</div>\\n''', + 'html_head': '''...<title></title>\\n'''} +"""], +["""\ ++++++ +Title ++++++ + +Subtitle +======== + +Some stuff + +Section +------- + +Some more stuff + +Another Section +............... + +And even more stuff +""", +"""\ +{'fragment': '''<p>Some stuff</p> +<div class="section"> +<h1><a id="section" name="section">Section</a></h1> +<p>Some more stuff</p> +<div class="section"> +<h2><a id="another-section" name="another-section">Another Section</a></h2> +<p>And even more stuff</p> +</div> +</div>\\n''', + 'html_body': '''<div class="document" id="title"> +<h1 class="title">Title</h1> +<h2 class="subtitle" id="subtitle">Subtitle</h2> +<p>Some stuff</p> +<div class="section"> +<h1><a id="section" name="section">Section</a></h1> +<p>Some more stuff</p> +<div class="section"> +<h2><a id="another-section" name="another-section">Another Section</a></h2> +<p>And even more stuff</p> +</div> +</div> +</div>\\n''', + 'html_head': '''...<title>Title</title>\\n''', + 'html_subtitle': '''<h2 class="subtitle" id="subtitle">Subtitle</h2>\\n''', + 'html_title': '''<h1 class="title">Title</h1>\\n''', + 'subtitle': '''Subtitle''', + 'title': '''Title'''} +"""], +["""\ ++++++ +Title ++++++ + +:author: me + +Some stuff +""", +"""\ +{'docinfo': '''<table class="docinfo" frame="void" rules="none"> +<col class="docinfo-name" /> +<col class="docinfo-content" /> +<tbody valign="top"> +<tr><th class="docinfo-name">Author:</th> +<td>me</td></tr> +</tbody> +</table>\\n''', + 'fragment': '''<p>Some stuff</p>\\n''', + 'html_body': '''<div class="document" id="title"> +<h1 class="title">Title</h1> +<table class="docinfo" frame="void" rules="none"> +<col class="docinfo-name" /> +<col class="docinfo-content" /> +<tbody valign="top"> +<tr><th class="docinfo-name">Author:</th> +<td>me</td></tr> +</tbody> +</table> +<p>Some stuff</p> +</div>\\n''', + 'html_head': '''...<title>Title</title> +<meta name="author" content="me" />\\n''', + 'html_title': '''<h1 class="title">Title</h1>\\n''', + 'meta': '''<meta name="author" content="me" />\\n''', + 'title': '''Title'''} +"""] +]) + +totest['No title promotion'] = ({'doctitle_xform' : 0, + 'stylesheet_path': '', + 'embed_stylesheet': 0}, [ +["""\ +Simple String +""", +"""\ +{'fragment': '''<p>Simple String</p>\\n''', + 'html_body': '''<div class="document"> +<p>Simple String</p> +</div>\\n''', + 'html_head': '''...<title></title>\\n'''} +"""], +["""\ +Simple String with *markup* +""", +"""\ +{'fragment': '''<p>Simple String with <em>markup</em></p>\\n''', + 'html_body': '''<div class="document"> +<p>Simple String with <em>markup</em></p> +</div>\\n''', + 'html_head': '''...<title></title>\\n'''} +"""], +["""\ +Simple String with an even simpler ``inline literal`` +""", +"""\ +{'fragment': '''<p>Simple String with an even simpler <tt class="docutils literal"><span class="pre">inline</span> <span class="pre">literal</span></tt></p>\\n''', + 'html_body': '''<div class="document"> +<p>Simple String with an even simpler <tt class="docutils literal"><span class="pre">inline</span> <span class="pre">literal</span></tt></p> +</div>\\n''', + 'html_head': '''...<title></title>\\n'''} +"""], +["""\ +A simple `anonymous reference`__ + +__ http://www.test.com/test_url +""", +"""\ +{'fragment': '''<p>A simple <a class="reference" href="http://www.test.com/test_url">anonymous reference</a></p>\\n''', + 'html_body': '''<div class="document"> +<p>A simple <a class="reference" href="http://www.test.com/test_url">anonymous reference</a></p> +</div>\\n''', + 'html_head': '''...<title></title>\\n'''} +"""], +["""\ +A simple `named reference`_ with stuff in between the +reference and the target. + +.. _`named reference`: http://www.test.com/test_url +""", +"""\ +{'fragment': '''<p>A simple <a class="reference" href="http://www.test.com/test_url">named reference</a> with stuff in between the +reference and the target.</p>\\n''', + 'html_body': '''<div class="document"> +<p>A simple <a class="reference" href="http://www.test.com/test_url">named reference</a> with stuff in between the +reference and the target.</p> +</div>\\n''', + 'html_head': '''...<title></title>\\n'''} +"""], +["""\ ++++++ +Title ++++++ + +Not A Subtitle +============== + +Some stuff + +Section +------- + +Some more stuff + +Another Section +............... + +And even more stuff +""", +"""\ +{'fragment': '''<div class="section"> +<h1><a id="title" name="title">Title</a></h1> +<div class="section"> +<h2><a id="not-a-subtitle" name="not-a-subtitle">Not A Subtitle</a></h2> +<p>Some stuff</p> +<div class="section"> +<h3><a id="section" name="section">Section</a></h3> +<p>Some more stuff</p> +<div class="section"> +<h4><a id="another-section" name="another-section">Another Section</a></h4> +<p>And even more stuff</p> +</div> +</div> +</div> +</div>\\n''', + 'html_body': '''<div class="document"> +<div class="section"> +<h1><a id="title" name="title">Title</a></h1> +<div class="section"> +<h2><a id="not-a-subtitle" name="not-a-subtitle">Not A Subtitle</a></h2> +<p>Some stuff</p> +<div class="section"> +<h3><a id="section" name="section">Section</a></h3> +<p>Some more stuff</p> +<div class="section"> +<h4><a id="another-section" name="another-section">Another Section</a></h4> +<p>And even more stuff</p> +</div> +</div> +</div> +</div> +</div>\\n''', + 'html_head': '''...<title></title>\\n'''} +"""], +["""\ +* bullet +* list +""", +"""\ +{'fragment': '''<ul class="simple"> +<li>bullet</li> +<li>list</li> +</ul>\\n''', + 'html_body': '''<div class="document"> +<ul class="simple"> +<li>bullet</li> +<li>list</li> +</ul> +</div>\\n''', + 'html_head': '''...<title></title>\\n'''} +"""], +["""\ +Not a docinfo. + +:This: .. _target: + + is +:a: +:simple: +:field: list +""", +"""\ +{'fragment': '''<p>Not a docinfo.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name">This:</th><td class="field-body"><p class="first last" id="target">is</p> +</td> +</tr> +<tr class="field"><th class="field-name">a:</th><td class="field-body"></td> +</tr> +<tr class="field"><th class="field-name">simple:</th><td class="field-body"></td> +</tr> +<tr class="field"><th class="field-name">field:</th><td class="field-body">list</td> +</tr> +</tbody> +</table>\\n''', + 'html_body': '''<div class="document"> +<p>Not a docinfo.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name">This:</th><td class="field-body"><p class="first last" id="target">is</p> +</td> +</tr> +<tr class="field"><th class="field-name">a:</th><td class="field-body"></td> +</tr> +<tr class="field"><th class="field-name">simple:</th><td class="field-body"></td> +</tr> +<tr class="field"><th class="field-name">field:</th><td class="field-body">list</td> +</tr> +</tbody> +</table> +</div>\\n''', + 'html_head': '''...<title></title>\\n'''} +"""], +]) + + +if __name__ == '__main__': + import unittest + unittest.main(defaultTest='suite') diff --git a/test/test_writers/test_html4css1_misc.py b/test/test_writers/test_html4css1_misc.py new file mode 100755 index 000000000..8b63d6f1c --- /dev/null +++ b/test/test_writers/test_html4css1_misc.py @@ -0,0 +1,36 @@ +#! /usr/bin/env python + +# Author: Felix Wiemann +# Contact: Felix_Wiemann@ososo.de +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. + +""" +Miscellaneous HTML writer tests. +""" + +from __init__ import DocutilsTestSupport +from docutils import core + + +class EncodingTestCase(DocutilsTestSupport.StandardTestCase): + + def test_xmlcharrefreplace(self): + # Test that xmlcharrefreplace is the default output encoding + # error handler. + settings_overrides={ + 'output_encoding': 'latin1', + 'stylesheet': '', + '_disable_config': 1,} + result = core.publish_string( + 'EUR = \xe2\x82\xac', writer_name='html4css1', + settings_overrides=settings_overrides) + # Encoding a euro sign with latin1 doesn't work, so the + # xmlcharrefreplcae handler is used. + self.assert_(result.find('EUR = €') != -1) + + +if __name__ == '__main__': + import unittest + unittest.main() diff --git a/test/test_writers/test_latex2e.py b/test/test_writers/test_latex2e.py new file mode 100755 index 000000000..04448883a --- /dev/null +++ b/test/test_writers/test_latex2e.py @@ -0,0 +1,377 @@ +#! /usr/bin/env python + +# Author: engelbert gruber +# Contact: grubert@users.sourceforge.net +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. + +""" +Tests for latex2e writer. +""" + +from __init__ import DocutilsTestSupport + +def suite(): + s = DocutilsTestSupport.PublishTestSuite('latex') + s.generateTests(totest) + return s + + +latex_head = """\ +\\documentclass[10pt,a4paper,english]{article} +\\usepackage{babel} +\\usepackage{ae} +\\usepackage{aeguill} +\\usepackage{shortvrb} +\\usepackage[latin1]{inputenc} +\\usepackage{tabularx} +\\usepackage{longtable} +\\setlength{\\extrarowheight}{2pt} +\\usepackage{amsmath} +\\usepackage{graphicx} +\\usepackage{color} +\\usepackage{multirow} +\\usepackage{ifthen} +\\usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref} +\\usepackage[DIV12]{typearea} +%% generator Docutils: http://docutils.sourceforge.net/ +\\newlength{\\admonitionwidth} +\\setlength{\\admonitionwidth}{0.9\\textwidth} +\\newlength{\\docinfowidth} +\\setlength{\\docinfowidth}{0.9\\textwidth} +\\newlength{\\locallinewidth} +\\newcommand{\\optionlistlabel}[1]{\\bf #1 \\hfill} +\\newenvironment{optionlist}[1] +{\\begin{list}{} + {\\setlength{\\labelwidth}{#1} + \\setlength{\\rightmargin}{1cm} + \\setlength{\\leftmargin}{\\rightmargin} + \\addtolength{\\leftmargin}{\\labelwidth} + \\addtolength{\\leftmargin}{\\labelsep} + \\renewcommand{\\makelabel}{\\optionlistlabel}} +}{\\end{list}} +\\newlength{\\lineblockindentation} +\\setlength{\\lineblockindentation}{2.5em} +\\newenvironment{lineblock}[1] +{\\begin{list}{} + {\\setlength{\\partopsep}{\\parskip} + \\addtolength{\\partopsep}{\\baselineskip} + \\topsep0pt\\itemsep0.15\\baselineskip\\parsep0pt + \\leftmargin#1} + \\raggedright} +{\\end{list}} +% begin: floats for footnotes tweaking. +\\setlength{\\floatsep}{0.5em} +\\setlength{\\textfloatsep}{\\fill} +\\addtolength{\\textfloatsep}{3em} +\\renewcommand{\\textfraction}{0.5} +\\renewcommand{\\topfraction}{0.5} +\\renewcommand{\\bottomfraction}{0.5} +\\setcounter{totalnumber}{50} +\\setcounter{topnumber}{50} +\\setcounter{bottomnumber}{50} +% end floats for footnotes +% some commands, that could be overwritten in the style file. +\\newcommand{\\rubric}[1]{\\subsection*{~\\hfill {\\it #1} \\hfill ~}} +\\newcommand{\\titlereference}[1]{\\textsl{#1}} +% end of "some commands" +""" + +totest = {} + +totest['table_of_contents'] = [ +# input +["""\ +.. contents:: Table of Contents + +Title 1 +======= +Paragraph 1. + +Title 2 +------- +Paragraph 2. +""", +## # expected output +latex_head + """\ +\\title{} +\\author{} +\\date{} +\\raggedbottom +\\begin{document} + +\\setlength{\\locallinewidth}{\\linewidth} +\\hypertarget{table-of-contents}{} +\\pdfbookmark[0]{Table of Contents}{table-of-contents} +\\subsubsection*{~\\hfill Table of Contents\\hfill ~} +\\begin{list}{}{} +\\item {} \\href{\\#title-1}{Title 1} +\\begin{list}{}{} +\\item {} \\href{\#title-2}{Title 2} + +\\end{list} + +\\end{list} + + + +%___________________________________________________________________________ + +\\hypertarget{title-1}{} +\\pdfbookmark[0]{Title 1}{title-1} +\\section*{Title 1} + +Paragraph 1. + + +%___________________________________________________________________________ + +\\hypertarget{title-2}{} +\\pdfbookmark[1]{Title 2}{title-2} +\\subsection*{Title 2} + +Paragraph 2. + +\\end{document} +"""], + +] + + +totest['enumerated_lists'] = [ +# input +["""\ +1. Item 1. +2. Second to the previous item this one will explain + + a) nothing. + b) or some other. + +3. Third is + + (I) having pre and postfixes + (II) in roman numerals. +""", +# expected output +latex_head + """\ +\\title{} +\\author{} +\\date{} +\\raggedbottom +\\begin{document} + +\\setlength{\\locallinewidth}{\\linewidth} +\\newcounter{listcnt1} +\\begin{list}{\\arabic{listcnt1}.} +{ +\\usecounter{listcnt1} +\\setlength{\\rightmargin}{\\leftmargin} +} +\\item {} +Item 1. + +\\item {} +Second to the previous item this one will explain + +\\end{list} +\\begin{quote} +\\newcounter{listcnt2} +\\begin{list}{\\alph{listcnt2})} +{ +\\usecounter{listcnt2} +\\setlength{\\rightmargin}{\\leftmargin} +} +\\item {} +nothing. + +\\item {} +or some other. + +\\end{list} +\\end{quote} +\\newcounter{listcnt3} +\\begin{list}{\\arabic{listcnt3}.} +{ +\\usecounter{listcnt3} +\\addtocounter{listcnt3}{2} +\\setlength{\\rightmargin}{\\leftmargin} +} +\\item {} +Third is + +\\end{list} +\\begin{quote} +\\newcounter{listcnt4} +\\begin{list}{(\\Roman{listcnt4})} +{ +\\usecounter{listcnt4} +\\setlength{\\rightmargin}{\\leftmargin} +} +\\item {} +having pre and postfixes + +\\item {} +in roman numerals. + +\\end{list} +\\end{quote} + +\\end{document} +"""], +] + +# BUG: need to test for quote replacing if language is de (ngerman). + +totest['quote_mangling'] = [ +# input +["""\ +Depending on language quotes are converted for latex. +Expecting "en" here. + +Inside literal blocks quotes should be left untouched +(use only two quotes in test code makes life easier for +the python interpreter running the test):: + + "" + This is left "untouched" also *this*. + "" + +.. parsed-literal:: + + should get "quotes" and *italics*. + + +Inline ``literal "quotes"`` should be kept. +""", +latex_head + """\ +\\title{} +\\author{} +\\date{} +\\raggedbottom +\\begin{document} + +\\setlength{\\locallinewidth}{\\linewidth} + +Depending on language quotes are converted for latex. +Expecting ``en'' here. + +Inside literal blocks quotes should be left untouched +(use only two quotes in test code makes life easier for +the python interpreter running the test): +\\begin{quote}{\\ttfamily \\raggedright \\noindent +"{}"~\\\\ +This~is~left~"untouched"~also~*this*.~\\\\ +"{}" +}\\end{quote} +\\begin{quote}{\\ttfamily \\raggedright \\noindent +should~get~"quotes"~and~\\emph{italics}. +}\\end{quote} + +Inline \\texttt{literal "quotes"} should be kept. + +\\end{document} +"""], +] + +totest['table_caption'] = [ +# input +["""\ +.. table:: Foo + + +-----+-----+ + | | | + +-----+-----+ + | | | + +-----+-----+ +""", +latex_head + """\ +\\title{} +\\author{} +\\date{} +\\raggedbottom +\\begin{document} + +\\setlength{\\locallinewidth}{\\linewidth} + +\\begin{longtable}[c]{|p{0.07\locallinewidth}|p{0.07\locallinewidth}|} +\\caption{Foo}\\\\ +\\hline + & \\\\ +\hline + & \\\\ +\hline +\\end{longtable} + +\\end{document} +"""], +] + +# In "\\\n[" the "[" needs to be protected (otherwise it will be seen as an option to "\\"). +totest['brackett_protection'] = [ +# input +["""\ +:: + + something before to get a end of line. + [ + + the empty line gets tested too + ] +""", +latex_head + """\ +\\title{} +\\author{} +\\date{} +\\raggedbottom +\\begin{document} + +\\setlength{\\locallinewidth}{\\linewidth} +\\begin{quote}{\\ttfamily \\raggedright \\noindent +something~before~to~get~a~end~of~line.~\\\\ +{[}~\\\\ +~\\\\ +the~empty~line~gets~tested~too~\\\\ +{]} +}\\end{quote} + +\\end{document} +"""], +] + +totest['raw'] = [ +["""\ +.. raw:: latex + + \\noindent + +A paragraph. + +.. |sub| raw:: latex + + (some raw text) + +Foo |sub| +same paragraph. +""", +latex_head + """\ +\\title{} +\\author{} +\\date{} +\\raggedbottom +\\begin{document} + +\\setlength{\\locallinewidth}{\\linewidth} +\\noindent +A paragraph. + +Foo (some raw text) +same paragraph. + +\\end{document} +"""], +] + +if __name__ == '__main__': + import unittest + unittest.main(defaultTest='suite') diff --git a/test/test_writers/test_null.py b/test/test_writers/test_null.py new file mode 100755 index 000000000..da385e565 --- /dev/null +++ b/test/test_writers/test_null.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python + +# Author: Felix Wiemann +# Contact: Felix_Wiemann@ososo.de +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. + +""" +Test for Null writer. +""" + +from __init__ import DocutilsTestSupport + +def suite(): + s = DocutilsTestSupport.PublishTestSuite('null') + s.generateTests(totest) + return s + +totest = {} + +totest['basic'] = [ +["""\ +This is a paragraph. +""", +None] +] + +if __name__ == '__main__': + import unittest + unittest.main(defaultTest='suite') diff --git a/test/test_writers/test_pseudoxml.py b/test/test_writers/test_pseudoxml.py new file mode 100755 index 000000000..db8bed7cb --- /dev/null +++ b/test/test_writers/test_pseudoxml.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python + +# Author: Felix Wiemann +# Contact: Felix_Wiemann@ososo.de +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. + +""" +Test for pseudo-XML writer. +""" + +from __init__ import DocutilsTestSupport + +def suite(): + s = DocutilsTestSupport.PublishTestSuite('pseudoxml') + s.generateTests(totest) + return s + +totest = {} + +totest['basic'] = [ +# input +["""\ +This is a paragraph. + +---------- + +This is another paragraph. + +A Section +--------- + +Foo. +""", +# output +"""\ +<document source="<string>"> + <paragraph> + This is a paragraph. + <transition> + <paragraph> + This is another paragraph. + <section ids="a-section" names="a\ section"> + <title> + A Section + <paragraph> + Foo. +"""] +] + +if __name__ == '__main__': + import unittest + unittest.main(defaultTest='suite') |
