Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 172557 | Differences between
and this patch

Collapse All | Expand All

(-)test/alltests.py (-11 lines)
Lines 19-39 Link Here
19
19
20
import sys
20
import sys
21
import os
21
import os
22
from types import UnicodeType
23
import DocutilsTestSupport              # must be imported before docutils
22
import DocutilsTestSupport              # must be imported before docutils
24
import docutils
23
import docutils
25
24
26
25
27
def new_exception_str(self):
28
    for i in self.args:
29
        if isinstance(i, UnicodeType):
30
            raise RuntimeError('Error (unicode): %r' % (self.args,))
31
    return old_exception_str(self)
32
33
old_exception_str = Exception.__str__
34
Exception.__str__ = new_exception_str
35
36
37
class Tee:
26
class Tee:
38
27
39
    """Write to a file and a stream (default: stdout) simultaneously."""
28
    """Write to a file and a stream (default: stdout) simultaneously."""
(-)test/test_parsers/test_rst/test_directives/test_images.py (-2 / +2 lines)
Lines 245-255 Link Here
245
        <paragraph>
245
        <paragraph>
246
            Error in "image" directive:
246
            Error in "image" directive:
247
            invalid option value: (option: "scale"; value: 'fifty')
247
            invalid option value: (option: "scale"; value: 'fifty')
248
            invalid literal for int(): fifty.
248
            %s.
249
        <literal_block xml:space="preserve">
249
        <literal_block xml:space="preserve">
250
            .. image:: picture.png
250
            .. image:: picture.png
251
               :scale: fifty
251
               :scale: fifty
252
"""],
252
""" % DocutilsTestSupport.exception_data('int("fifty")')[1][0]],
253
["""\
253
["""\
254
.. image:: picture.png
254
.. image:: picture.png
255
   :scale: 50
255
   :scale: 50
(-)test/test_parsers/test_rst/test_directives/test_contents.py (-2 / +2 lines)
Lines 151-161 Link Here
151
        <paragraph>
151
        <paragraph>
152
            Error in "contents" directive:
152
            Error in "contents" directive:
153
            invalid option value: (option: "depth"; value: 'two')
153
            invalid option value: (option: "depth"; value: 'two')
154
            invalid literal for int(): two.
154
            %s.
155
        <literal_block xml:space="preserve">
155
        <literal_block xml:space="preserve">
156
            .. contents::
156
            .. contents::
157
               :depth: two
157
               :depth: two
158
"""],
158
""" % DocutilsTestSupport.exception_data('int("two")')[1][0]],
159
["""\
159
["""\
160
.. contents::
160
.. contents::
161
   :width: 2
161
   :width: 2
(-)test/test_parsers/test_rst/test_directives/test_tables.py (-4 / +14 lines)
Lines 34-39 Link Here
34
else:
34
else:
35
    unichr_exception_string = str(unichr_exception)
35
    unichr_exception_string = str(unichr_exception)
36
36
37
null_bytes_code = """
38
import csv
39
import cStringIO
40
csv_data = open('%s', 'rb').read().decode('latin-1')
41
csv_file = cStringIO.StringIO(csv_data)
42
reader = csv.reader(csv_file)
43
reader.next()
44
""" % utf_16_csv
45
null_bytes_exception = DocutilsTestSupport.exception_data(null_bytes_code)[1][0]
46
37
totest = {}
47
totest = {}
38
48
39
totest['table'] = [
49
totest['table'] = [
Lines 549-555 Link Here
549
        <paragraph>
559
        <paragraph>
550
            Error in "csv-table" directive:
560
            Error in "csv-table" directive:
551
            invalid option value: (option: "widths"; value: '10,y,z')
561
            invalid option value: (option: "widths"; value: '10,y,z')
552
            invalid literal for int(): y.
562
            %s.
553
        <literal_block xml:space="preserve">
563
        <literal_block xml:space="preserve">
554
            .. csv-table:: bad column widths
564
            .. csv-table:: bad column widths
555
               :widths: 10,y,z
565
               :widths: 10,y,z
Lines 565-571 Link Here
565
               :widths: 0 0 0
575
               :widths: 0 0 0
566
            \n\
576
            \n\
567
               some, csv, data
577
               some, csv, data
568
"""],
578
""" % DocutilsTestSupport.exception_data('int("y")')[1][0]],
569
["""\
579
["""\
570
.. csv-table:: good delimiter
580
.. csv-table:: good delimiter
571
   :delim: /
581
   :delim: /
Lines 734-747 Link Here
734
    <system_message level="3" line="1" source="test data" type="ERROR">
744
    <system_message level="3" line="1" source="test data" type="ERROR">
735
        <paragraph>
745
        <paragraph>
736
            Error with CSV data in "csv-table" directive:
746
            Error with CSV data in "csv-table" directive:
737
            string with NUL bytes
747
            %s
738
        <literal_block xml:space="preserve">
748
        <literal_block xml:space="preserve">
739
            .. csv-table:: bad encoding
749
            .. csv-table:: bad encoding
740
               :file: %s
750
               :file: %s
741
               :encoding: latin-1
751
               :encoding: latin-1
742
    <paragraph>
752
    <paragraph>
743
        (7- and 8-bit text encoded as UTF-16 has lots of null/zero bytes.)
753
        (7- and 8-bit text encoded as UTF-16 has lots of null/zero bytes.)
744
""" % utf_16_csv],
754
""" % (null_bytes_exception, utf_16_csv)],
745
["""\
755
["""\
746
.. csv-table:: good encoding
756
.. csv-table:: good encoding
747
   :file: %s
757
   :file: %s
(-)docutils/parsers/rst/directives/tables.py (-1 / +2 lines)
Lines 259-265 Link Here
259
259
260
def parse_csv_data_into_rows(csv_data, dialect, source, options):
260
def parse_csv_data_into_rows(csv_data, dialect, source, options):
261
    # csv.py doesn't do Unicode; encode temporarily as UTF-8
261
    # csv.py doesn't do Unicode; encode temporarily as UTF-8
262
    csv_reader = csv.reader([line.encode('utf-8') for line in csv_data],
262
    csv_reader = csv.reader([(line.encode('utf-8') + '\n')
263
                             for line in csv_data],
263
                            dialect=dialect)
264
                            dialect=dialect)
264
    rows = []
265
    rows = []
265
    max_cols = 0
266
    max_cols = 0

Return to bug 172557