diff options
author | wiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2006-01-09 20:44:25 +0000 |
---|---|---|
committer | wiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2006-01-09 20:44:25 +0000 |
commit | d77fdfef70e08114f57cbef5d91707df8717ea9f (patch) | |
tree | 49444e3486c0c333cb7b33dfa721296c08ee4ece /test/test_writers/test_docutils_xml.py | |
parent | 53cd16ca6ca5f638cbe5956988e88f9339e355cf (diff) | |
parent | 3993c4097756e9885bcfbd07cb1cc1e4e95e50e4 (diff) | |
download | docutils-0.4.tar.gz |
Release 0.4: tagging released revisiondocutils-0.4
git-svn-id: http://svn.code.sf.net/p/docutils/code/tags/docutils-0.4@4268 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'test/test_writers/test_docutils_xml.py')
-rwxr-xr-x | test/test_writers/test_docutils_xml.py | 86 |
1 files changed, 86 insertions, 0 deletions
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() |