~ubuntu-branches/ubuntu/karmic/python-docutils/karmic

« back to all changes in this revision

Viewing changes to test/test_writers/test_docutils_xml.py

  • Committer: Bazaar Package Importer
  • Author(s): martin f. krafft
  • Date: 2006-07-10 11:45:05 UTC
  • mfrom: (2.1.4 edgy)
  • Revision ID: james.westby@ubuntu.com-20060710114505-otkhqcslevewxmz5
Tags: 0.4-3
Added build dependency on python-central (closes: #377580).

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
# Author: Felix Wiemann
4
4
# Contact: Felix_Wiemann@ososo.de
5
 
# Revision: $Revision: 1.4 $
6
 
# Date: $Date: 2004/05/07 15:15:09 $
 
5
# Revision: $Revision: 3968 $
 
6
# Date: $Date: 2005-10-29 14:28:44 +0200 (Sat, 29 Oct 2005) $
7
7
# Copyright: This module has been placed in the public domain.
8
8
 
9
9
"""
10
10
Test for docutils XML writer.
11
11
"""
12
12
 
13
 
import unittest
 
13
from __init__ import DocutilsTestSupport
14
14
 
15
15
import docutils
16
16
import docutils.core
17
17
 
18
18
 
19
 
class DocutilsXMLTestCase(unittest.TestCase, docutils.SettingsSpec):
20
 
 
21
 
    input = 'Test\n====\n\nSubsection\n----------\n\nTest\n\n----------\n\nTest.'
 
19
class DocutilsXMLTestCase(DocutilsTestSupport.StandardTestCase):
 
20
 
 
21
    input = """\
 
22
Test
 
23
 
 
24
----------
 
25
 
 
26
Test. \xc3\xa4\xc3\xb6\xc3\xbc\xe2\x82\xac"""
22
27
    xmldecl = '<?xml version="1.0" encoding="iso-8859-1"?>\n'
23
 
    doctypedecl = '<!DOCTYPE document PUBLIC "+//IDN docutils.sourceforge.net//DTD Docutils Generic//EN//XML" "http://docutils.sourceforge.net/spec/docutils.dtd">\n'
 
28
    doctypedecl = '<!DOCTYPE document PUBLIC "+//IDN docutils.sourceforge.net//DTD Docutils Generic//EN//XML" "http://docutils.sourceforge.net/docs/ref/docutils.dtd">\n'
24
29
    generatedby = '<!-- Generated by Docutils %s -->\n' % docutils.__version__
25
 
    bodynormal = '<document id="test" name="test" source="&lt;string&gt;"><title>Test</title><subtitle id="subsection" name="subsection">Subsection</subtitle><paragraph>Test</paragraph><transition/><paragraph>Test.</paragraph></document>'
26
 
    bodynormal = '<document id="test" name="test" source="&lt;string&gt;"><title>Test</title><subtitle id="subsection" name="subsection">Subsection</subtitle><paragraph>Test</paragraph><transition/><paragraph>Test.</paragraph></document>'
27
 
    bodynewlines = '<document id="test" name="test" source="&lt;string&gt;">\n<title>\nTest\n</title>\n<subtitle id="subsection" name="subsection">\nSubsection\n</subtitle>\n<paragraph>\nTest\n</paragraph>\n<transition/>\n<paragraph>\nTest.\n</paragraph>\n</document>\n'
28
 
    bodyindents = '<document id="test" name="test" source="&lt;string&gt;">\n    <title>\n        Test\n    </title>\n    <subtitle id="subsection" name="subsection">\n        Subsection\n    </subtitle>\n    <paragraph>\n        Test\n    </paragraph>\n    <transition/>\n    <paragraph>\n        Test.\n    </paragraph>\n</document>\n'
29
 
 
30
 
    settings_default_overrides = {'_disable_config': 1}
 
30
    bodynormal = '<document source="&lt;string&gt;"><paragraph>Test</paragraph><transition/><paragraph>Test. \xe4\xf6\xfc&#8364;</paragraph></document>'
 
31
    bodynewlines = """\
 
32
<document source="&lt;string&gt;">
 
33
<paragraph>
 
34
Test
 
35
</paragraph>
 
36
<transition/>
 
37
<paragraph>
 
38
Test. \xe4\xf6\xfc&#8364;
 
39
</paragraph>
 
40
</document>
 
41
"""
 
42
    bodyindents = """\
 
43
<document source="&lt;string&gt;">
 
44
    <paragraph>
 
45
        Test
 
46
    </paragraph>
 
47
    <transition/>
 
48
    <paragraph>
 
49
        Test. \xe4\xf6\xfc&#8364;
 
50
    </paragraph>
 
51
</document>
 
52
"""
31
53
 
32
54
    def test_publish(self):
33
 
        settings = {'output_encoding': 'iso-8859-1'}
 
55
        settings = {'input_encoding': 'utf8',
 
56
                    'output_encoding': 'iso-8859-1',
 
57
                    '_disable_config': 1}
34
58
        for settings['newlines'] in 0, 1:
35
59
            for settings['indents'] in 0, 1:
36
60
                for settings['xml_declaration'] in 0, 1:
53
77
                                         (source=self.input,
54
78
                                          reader_name='standalone',
55
79
                                          writer_name='docutils_xml',
56
 
                                          settings_spec=self,
57
80
                                          settings_overrides=settings),
58
81
                                         expected)
59
82
 
60
83
 
61
84
if __name__ == '__main__':
 
85
    import unittest
62
86
    unittest.main()