~ubuntu-branches/ubuntu/quantal/python-docutils/quantal

« back to all changes in this revision

Viewing changes to test/test_parsers/test_rst/test_directives/test_raw.py

  • Committer: Bazaar Package Importer
  • Author(s): Jakub Wilk
  • Date: 2009-12-13 19:54:12 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20091213195412-9o7q348lfkucx01f
* Unconditionally recommend python-lxml, as it is used by
  /usr/bin/rst2odt_prepstyles (closes: #560330).
* Demote dependency on an ElementTree implementation to recommendation, as it
  is only used by /usr/bin/rst2odt; remove python-lxml from alternatives, as
  it is never used by the script (closes: #560328).
* Fix insecure use of temporary files in the Emacs major mode for
  reStructuredText (closes: #560755). Thanks to Kumar Appaiah for helping to
  deal with this bug.
* Register docutils documentation using doc-base.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#! /usr/bin/env python
2
2
 
3
 
# $Id: test_raw.py 5033 2007-03-21 19:51:22Z wiemann $
 
3
# $Id: test_raw.py 5889 2009-04-01 20:00:21Z gbrandl $
4
4
# Author: David Goodger <goodger@python.org>
5
5
# Copyright: This module has been placed in the public domain.
6
6
 
11
11
import os.path
12
12
import sys
13
13
from __init__ import DocutilsTestSupport
14
 
 
 
14
from docutils._compat import u_prefix, b
15
15
 
16
16
def suite():
17
17
    s = DocutilsTestSupport.ParserTestSuite()
92
92
   :file: %s
93
93
   :encoding: utf-16
94
94
""" % utf_16_file_rel,
95
 
"""\
 
95
b("""\
96
96
<document source="test data">
97
97
    <raw format="html" source="%s" xml:space="preserve">
98
98
        "Treat", "Quantity", "Description"
100
100
        "Crunchy Frog", 1.49, "If we took the b\xf6nes out, it wouldn\\u2019t be
101
101
        crunchy, now would it?"
102
102
        "Gannet Ripple", 1.99, "\xbfOn a \\u03c3\\u03c4\\u03b9\\u03ba?"
103
 
""" % utf_16_file_rel],
 
103
""" % utf_16_file_rel).decode('raw_unicode_escape')],
104
104
["""\
105
105
Raw input file is UTF-16-encoded, and is not valid ASCII.
106
106
 
122
122
               :file: %s
123
123
               :encoding: ascii
124
124
""" % utf_16_file_rel],
125
 
["""\
 
125
[u"""\
126
126
.. raw:: html
127
127
   :encoding: utf-8
128
128
 
153
153
    <system_message level="4" line="1" source="test data" type="SEVERE">
154
154
        <paragraph>
155
155
            Problems with "raw" directive path:
156
 
            [Errno 2] No such file or directory: 'non-existent.file'.
 
156
            [Errno 2] No such file or directory: %s'non-existent.file'.
157
157
        <literal_block xml:space="preserve">
158
158
            .. raw:: html
159
159
               :file: non-existent.file
160
 
"""],
 
160
""" % u_prefix],
 
161
# note that this output is rewritten below for certain python versions
161
162
]
162
163
 
163
 
# Skip tests whose output contains "UnicodeDecodeError" if we are not
164
 
# using Python 2.3 or higher.
165
 
if sys.version_info < (2, 3):
166
 
    for i in range(len(totest['raw'])):
167
 
        if totest['raw'][i][1].find('UnicodeDecodeError') != -1:
168
 
            del totest['raw'][i]
169
 
            print ("Test totest['raw'][%s] skipped; "
170
 
                   "Python 2.3+ required for expected output." % i)
171
 
            # Assume we have only one of these tests.
172
 
            break
 
164
# Rewrite tests that depend on the output of IOError as it is
 
165
# platform-dependent before python 2.4 for a unicode path.
 
166
if sys.version_info < (2, 4):
 
167
    # remove the unicode repr u except for py2.3 on windows:
 
168
    if not sys.platform.startswith('win') or sys.version_info < (2, 3):
 
169
        for i in range(len(totest['raw'])):
 
170
            if totest['raw'][i][1].find("u'non-existent.file'") != -1:
 
171
                totest['raw'][i][1] = totest['raw'][i][1].replace(
 
172
                        "u'non-existent.file'", "'non-existent.file'")
173
173
 
174
174
 
175
175
if __name__ == '__main__':