blob: 878c6f1961db8b5793b8bdcb36dff5fed60c9b5c [file] [log] [blame]
Combination of:
http://svn.code.sf.net/p/docutils/code/trunk@8910
http://svn.code.sf.net/p/docutils/code/trunk@8909
diff --git a/test/DocutilsTestSupport.py b/test/DocutilsTestSupport.py
index 592d3f9df..e1f33aa7a 100644
--- a/test/DocutilsTestSupport.py
+++ b/test/DocutilsTestSupport.py
@@ -819,6 +819,7 @@ def exception_data(func, *args, **kwds):
except Exception as detail:
return (detail, detail.args,
'%s: %s' % (detail.__class__.__name__, detail))
+ return None, [], "No exception"
def _format_str(*args):
diff --git a/test/test_parsers/test_rst/test_directives/test_tables.py b/test/test_parsers/test_rst/test_directives/test_tables.py
index 07be0122f..73724ed7e 100755
--- a/test/test_parsers/test_rst/test_directives/test_tables.py
+++ b/test/test_parsers/test_rst/test_directives/test_tables.py
@@ -65,6 +65,92 @@ def null_bytes():
next(reader)
null_bytes_exception = DocutilsTestSupport.exception_data(null_bytes)[0]
+# Null bytes are valid in Python 3.11+:
+if null_bytes_exception is None:
+ bad_encoding_result = """\
+<document source="test data">
+ <table>
+ <title>
+ bad encoding
+ <tgroup cols="4">
+ <colspec colwidth="25">
+ <colspec colwidth="25">
+ <colspec colwidth="25">
+ <colspec colwidth="25">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ \xfe\xff"Treat"
+ <entry>
+ <paragraph>
+ "Quantity"
+ <entry>
+ <paragraph>
+ "Description"
+ <entry>
+ <row>
+ <entry>
+ <paragraph>
+ "Albatr\u00b0\u00df"
+ <entry>
+ <paragraph>
+ 2.99
+ <entry>
+ <paragraph>
+ "\u00a1Ona\x03\xc3\x03\xc4\x03\xb9\x03\xba!"
+ <entry>
+ <row>
+ <entry>
+ <paragraph>
+ "CrunchyFrog"
+ <entry>
+ <paragraph>
+ 1.49
+ <entry>
+ <paragraph>
+ "Ifwetooktheb\u00f6nesout
+ <entry>
+ <paragraph>
+ itwouldn\x20\x19tbe
+ <row>
+ <entry>
+ <paragraph>
+ crunchy
+ <entry>
+ <paragraph>
+ nowwouldit?"
+ <entry>
+ <entry>
+ <row>
+ <entry>
+ <paragraph>
+ "GannetRipple"
+ <entry>
+ <paragraph>
+ 1.99
+ <entry>
+ <paragraph>
+ "\xbfOna\x03\xc3\x03\xc4\x03\xb9\x03\xba?"
+ <entry>
+ <paragraph>
+ (7- and 8-bit text encoded as UTF-16 has lots of null/zero bytes.)
+"""
+else:
+ bad_encoding_result = """\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error with CSV data in "csv-table" directive:
+ %s
+ <literal_block xml:space="preserve">
+ .. csv-table:: bad encoding
+ :file: %s
+ :encoding: latin-1
+ <paragraph>
+ (7- and 8-bit text encoded as UTF-16 has lots of null/zero bytes.)
+""" % (null_bytes_exception, utf_16_csv)
+
totest = {}
@@ -1031,19 +1117,8 @@ u"""\
(7- and 8-bit text encoded as UTF-16 has lots of null/zero bytes.)
""" % utf_16_csv,
-"""\
-<document source="test data">
- <system_message level="3" line="1" source="test data" type="ERROR">
- <paragraph>
- Error with CSV data in "csv-table" directive:
- %s
- <literal_block xml:space="preserve">
- .. csv-table:: bad encoding
- :file: %s
- :encoding: latin-1
- <paragraph>
- (7- and 8-bit text encoded as UTF-16 has lots of null/zero bytes.)
-""" % (null_bytes_exception, utf_16_csv)],
+bad_encoding_result
+],
["""\
.. csv-table:: good encoding
:file: %s