| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
""" |
| 8 |
Tests for tables.py directives. |
| 9 |
""" |
| 10 |
|
| 11 |
import os |
| 12 |
import csv |
| 13 |
import platform |
| 14 |
from pathlib import Path |
| 15 |
import sys |
| 16 |
import unittest |
| 17 |
|
| 18 |
if __name__ == '__main__': |
| 19 |
|
| 20 |
|
| 21 |
sys.path.insert(0, str(Path(__file__).resolve().parents[4])) |
| 22 |
|
| 23 |
from docutils.frontend import get_default_settings |
| 24 |
from docutils.parsers.rst import Parser |
| 25 |
from docutils.utils import new_document |
| 26 |
|
| 27 |
|
| 28 |
TEST_ROOT = os.path.abspath(os.path.join(__file__, '..', '..', '..', '..')) |
| 29 |
|
| 30 |
|
| 31 |
class ParserTestCase(unittest.TestCase): |
| 32 |
|
| 33 |
maxDiff = None |
| 34 |
|
| 35 |
def test_parser(self): |
| 36 |
parser = Parser() |
| 37 |
settings = get_default_settings(Parser) |
| 38 |
settings.warning_stream = '' |
| 39 |
settings.halt_level = 5 |
| 40 |
for name, cases in totest.items(): |
| 41 |
for casenum, (case_input, case_expected) in enumerate(cases): |
| 42 |
with self.subTest(id=f'totest[{name!r}][{casenum}]'): |
| 43 |
document = new_document('test data', settings.copy()) |
| 44 |
parser.parse(case_input, document) |
| 45 |
output = document.pformat() |
| 46 |
self.assertEqual(case_expected, output) |
| 47 |
|
| 48 |
|
| 49 |
mydir = os.path.join(TEST_ROOT, 'test_parsers/test_rst/test_directives') |
| 50 |
utf_16_csv = os.path.join(mydir, 'utf-16.csv') |
| 51 |
empty_txt = os.path.join(mydir, 'empty.rst') |
| 52 |
|
| 53 |
try: |
| 54 |
chr(0x9999999999999) |
| 55 |
except OverflowError as unichr_exception: |
| 56 |
unichr_exception_string = f'code too large ({unichr_exception})' |
| 57 |
except Exception as unichr_exception: |
| 58 |
unichr_exception_string = str(unichr_exception) |
| 59 |
else: |
| 60 |
unichr_exception_string = '' |
| 61 |
|
| 62 |
csv_eod_error_str = 'unexpected end of data' |
| 63 |
|
| 64 |
if platform.python_implementation() == 'PyPy': |
| 65 |
csv_eod_error_str = 'line 1: ' + csv_eod_error_str |
| 66 |
csv_unknown_url = "'bogus.csv'" |
| 67 |
|
| 68 |
|
| 69 |
try: |
| 70 |
csv_data = Path(utf_16_csv).read_bytes() |
| 71 |
csv_data = str(csv_data, 'latin1').splitlines() |
| 72 |
reader = csv.reader([line + '\n' for line in csv_data]) |
| 73 |
next(reader) |
| 74 |
except Exception as detail: |
| 75 |
null_bytes_exception = detail |
| 76 |
else: |
| 77 |
null_bytes_exception = None |
| 78 |
|
| 79 |
|
| 80 |
if null_bytes_exception is None: |
| 81 |
bad_encoding_result = """\ |
| 82 |
<document source="test data"> |
| 83 |
<table> |
| 84 |
<title> |
| 85 |
bad encoding |
| 86 |
<tgroup cols="4"> |
| 87 |
<colspec colwidth="25"> |
| 88 |
<colspec colwidth="25"> |
| 89 |
<colspec colwidth="25"> |
| 90 |
<colspec colwidth="25"> |
| 91 |
<tbody> |
| 92 |
<row> |
| 93 |
<entry> |
| 94 |
<paragraph> |
| 95 |
\xfe\xff"Treat" |
| 96 |
<entry> |
| 97 |
<paragraph> |
| 98 |
"Quantity" |
| 99 |
<entry> |
| 100 |
<paragraph> |
| 101 |
"Description" |
| 102 |
<entry> |
| 103 |
<row> |
| 104 |
<entry> |
| 105 |
<paragraph> |
| 106 |
"Albatr\u00b0\u00df" |
| 107 |
<entry> |
| 108 |
<paragraph> |
| 109 |
2.99 |
| 110 |
<entry> |
| 111 |
<paragraph> |
| 112 |
"\u00a1Ona\x03\xc3\x03\xc4\x03\xb9\x03\xba!" |
| 113 |
<entry> |
| 114 |
<row> |
| 115 |
<entry> |
| 116 |
<paragraph> |
| 117 |
"CrunchyFrog" |
| 118 |
<entry> |
| 119 |
<paragraph> |
| 120 |
1.49 |
| 121 |
<entry> |
| 122 |
<paragraph> |
| 123 |
"Ifwetooktheb\u00f6nesout |
| 124 |
<entry> |
| 125 |
<paragraph> |
| 126 |
itwouldn\x20\x19tbe |
| 127 |
<row> |
| 128 |
<entry> |
| 129 |
<paragraph> |
| 130 |
crunchy |
| 131 |
<entry> |
| 132 |
<paragraph> |
| 133 |
nowwouldit?" |
| 134 |
<entry> |
| 135 |
<entry> |
| 136 |
<row> |
| 137 |
<entry> |
| 138 |
<paragraph> |
| 139 |
"GannetRipple" |
| 140 |
<entry> |
| 141 |
<paragraph> |
| 142 |
1.99 |
| 143 |
<entry> |
| 144 |
<paragraph> |
| 145 |
"\xbfOna\x03\xc3\x03\xc4\x03\xb9\x03\xba?" |
| 146 |
<entry> |
| 147 |
<paragraph> |
| 148 |
(7- and 8-bit text encoded as UTF-16 has lots of null/zero bytes.) |
| 149 |
""" |
| 150 |
else: |
| 151 |
bad_encoding_result = """\ |
| 152 |
<document source="test data"> |
| 153 |
<system_message level="3" line="1" source="test data" type="ERROR"> |
| 154 |
<paragraph> |
| 155 |
Error with CSV data in "csv-table" directive: |
| 156 |
%s |
| 157 |
<literal_block xml:space="preserve"> |
| 158 |
.. csv-table:: bad encoding |
| 159 |
:file: %s |
| 160 |
:encoding: latin-1 |
| 161 |
<paragraph> |
| 162 |
(7- and 8-bit text encoded as UTF-16 has lots of null/zero bytes.) |
| 163 |
""" % (null_bytes_exception, utf_16_csv) |
| 164 |
|
| 165 |
try: |
| 166 |
int('y') |
| 167 |
except ValueError as detail: |
| 168 |
invalid_literal = detail.args[0] |
| 169 |
else: |
| 170 |
invalid_literal = '' |
| 171 |
|
| 172 |
totest = {} |
| 173 |
|
| 174 |
totest['table'] = [ |
| 175 |
["""\ |
| 176 |
.. table:: Truth table for "not" |
| 177 |
:class: custom |
| 178 |
:name: tab:truth.not |
| 179 |
|
| 180 |
===== ===== |
| 181 |
A not A |
| 182 |
===== ===== |
| 183 |
False True |
| 184 |
True False |
| 185 |
===== ===== |
| 186 |
""", |
| 187 |
"""\ |
| 188 |
<document source="test data"> |
| 189 |
<table classes="custom" ids="tab-truth-not" names="tab:truth.not"> |
| 190 |
<title> |
| 191 |
Truth table for "not" |
| 192 |
<tgroup cols="2"> |
| 193 |
<colspec colwidth="5"> |
| 194 |
<colspec colwidth="5"> |
| 195 |
<thead> |
| 196 |
<row> |
| 197 |
<entry> |
| 198 |
<paragraph> |
| 199 |
A |
| 200 |
<entry> |
| 201 |
<paragraph> |
| 202 |
not A |
| 203 |
<tbody> |
| 204 |
<row> |
| 205 |
<entry> |
| 206 |
<paragraph> |
| 207 |
False |
| 208 |
<entry> |
| 209 |
<paragraph> |
| 210 |
True |
| 211 |
<row> |
| 212 |
<entry> |
| 213 |
<paragraph> |
| 214 |
True |
| 215 |
<entry> |
| 216 |
<paragraph> |
| 217 |
False |
| 218 |
"""], |
| 219 |
["""\ |
| 220 |
.. table:: |
| 221 |
|
| 222 |
========== ========== |
| 223 |
Table without |
| 224 |
a title |
| 225 |
========== ========== |
| 226 |
""", |
| 227 |
"""\ |
| 228 |
<document source="test data"> |
| 229 |
<table> |
| 230 |
<tgroup cols="2"> |
| 231 |
<colspec colwidth="10"> |
| 232 |
<colspec colwidth="10"> |
| 233 |
<tbody> |
| 234 |
<row> |
| 235 |
<entry> |
| 236 |
<paragraph> |
| 237 |
Table |
| 238 |
<entry> |
| 239 |
<paragraph> |
| 240 |
without |
| 241 |
<row> |
| 242 |
<entry> |
| 243 |
<paragraph> |
| 244 |
a |
| 245 |
<entry> |
| 246 |
<paragraph> |
| 247 |
title |
| 248 |
"""], |
| 249 |
["""\ |
| 250 |
.. table:: title with an *error |
| 251 |
|
| 252 |
====== ===== |
| 253 |
Simple table |
| 254 |
====== ===== |
| 255 |
""", |
| 256 |
"""\ |
| 257 |
<document source="test data"> |
| 258 |
<table> |
| 259 |
<title> |
| 260 |
title with an \n\ |
| 261 |
<problematic ids="problematic-1" refid="system-message-1"> |
| 262 |
* |
| 263 |
error |
| 264 |
<tgroup cols="2"> |
| 265 |
<colspec colwidth="6"> |
| 266 |
<colspec colwidth="5"> |
| 267 |
<tbody> |
| 268 |
<row> |
| 269 |
<entry> |
| 270 |
<paragraph> |
| 271 |
Simple |
| 272 |
<entry> |
| 273 |
<paragraph> |
| 274 |
table |
| 275 |
<system_message backrefs="problematic-1" ids="system-message-1" level="2" line="1" source="test data" type="WARNING"> |
| 276 |
<paragraph> |
| 277 |
Inline emphasis start-string without end-string. |
| 278 |
"""], |
| 279 |
["""\ |
| 280 |
.. table:: Not a table. |
| 281 |
|
| 282 |
This is a paragraph. |
| 283 |
""", |
| 284 |
"""\ |
| 285 |
<document source="test data"> |
| 286 |
<system_message level="3" line="1" source="test data" type="ERROR"> |
| 287 |
<paragraph> |
| 288 |
Error parsing content block for the "table" directive: exactly one table expected. |
| 289 |
<literal_block xml:space="preserve"> |
| 290 |
.. table:: Not a table. |
| 291 |
\n\ |
| 292 |
This is a paragraph. |
| 293 |
"""], |
| 294 |
["""\ |
| 295 |
.. table:: empty |
| 296 |
""", |
| 297 |
"""\ |
| 298 |
<document source="test data"> |
| 299 |
<system_message level="2" line="1" source="test data" type="WARNING"> |
| 300 |
<paragraph> |
| 301 |
Content block expected for the "table" directive; none found. |
| 302 |
<literal_block xml:space="preserve"> |
| 303 |
.. table:: empty |
| 304 |
"""], |
| 305 |
["""\ |
| 306 |
.. table:: |
| 307 |
:width: 100 % |
| 308 |
|
| 309 |
============ ============== |
| 310 |
col 1 col 2 |
| 311 |
============ ============== |
| 312 |
""", |
| 313 |
"""\ |
| 314 |
<document source="test data"> |
| 315 |
<table width="100%"> |
| 316 |
<tgroup cols="2"> |
| 317 |
<colspec colwidth="12"> |
| 318 |
<colspec colwidth="14"> |
| 319 |
<tbody> |
| 320 |
<row> |
| 321 |
<entry> |
| 322 |
<paragraph> |
| 323 |
col 1 |
| 324 |
<entry> |
| 325 |
<paragraph> |
| 326 |
col 2 |
| 327 |
"""], |
| 328 |
["""\ |
| 329 |
.. table:: |
| 330 |
:width: 100px |
| 331 |
|
| 332 |
============ ============== |
| 333 |
col 1 col 2 |
| 334 |
============ ============== |
| 335 |
""", |
| 336 |
"""\ |
| 337 |
<document source="test data"> |
| 338 |
<table width="100px"> |
| 339 |
<tgroup cols="2"> |
| 340 |
<colspec colwidth="12"> |
| 341 |
<colspec colwidth="14"> |
| 342 |
<tbody> |
| 343 |
<row> |
| 344 |
<entry> |
| 345 |
<paragraph> |
| 346 |
col 1 |
| 347 |
<entry> |
| 348 |
<paragraph> |
| 349 |
col 2 |
| 350 |
"""], |
| 351 |
["""\ |
| 352 |
.. table:: |
| 353 |
:width: 321 |
| 354 |
|
| 355 |
============ ============== |
| 356 |
col 1 col 2 |
| 357 |
============ ============== |
| 358 |
""", |
| 359 |
"""\ |
| 360 |
<document source="test data"> |
| 361 |
<table width="321"> |
| 362 |
<tgroup cols="2"> |
| 363 |
<colspec colwidth="12"> |
| 364 |
<colspec colwidth="14"> |
| 365 |
<tbody> |
| 366 |
<row> |
| 367 |
<entry> |
| 368 |
<paragraph> |
| 369 |
col 1 |
| 370 |
<entry> |
| 371 |
<paragraph> |
| 372 |
col 2 |
| 373 |
"""], |
| 374 |
["""\ |
| 375 |
.. table:: |
| 376 |
:widths: 15, 25 |
| 377 |
|
| 378 |
============ ============== |
| 379 |
Columns with custom widths. |
| 380 |
============ ============== |
| 381 |
""", |
| 382 |
"""\ |
| 383 |
<document source="test data"> |
| 384 |
<table classes="colwidths-given"> |
| 385 |
<tgroup cols="2"> |
| 386 |
<colspec colwidth="15"> |
| 387 |
<colspec colwidth="25"> |
| 388 |
<tbody> |
| 389 |
<row> |
| 390 |
<entry> |
| 391 |
<paragraph> |
| 392 |
Columns with |
| 393 |
<entry> |
| 394 |
<paragraph> |
| 395 |
custom widths. |
| 396 |
"""], |
| 397 |
["""\ |
| 398 |
.. table:: |
| 399 |
:widths: 10, 20 |
| 400 |
|
| 401 |
+--------------+----------------+ |
| 402 |
| Columns with | custom widths. | |
| 403 |
+--------------+----------------+ |
| 404 |
""", |
| 405 |
"""\ |
| 406 |
<document source="test data"> |
| 407 |
<table classes="colwidths-given"> |
| 408 |
<tgroup cols="2"> |
| 409 |
<colspec colwidth="10"> |
| 410 |
<colspec colwidth="20"> |
| 411 |
<tbody> |
| 412 |
<row> |
| 413 |
<entry> |
| 414 |
<paragraph> |
| 415 |
Columns with |
| 416 |
<entry> |
| 417 |
<paragraph> |
| 418 |
custom widths. |
| 419 |
"""], |
| 420 |
["""\ |
| 421 |
.. table:: |
| 422 |
:widths: auto |
| 423 |
|
| 424 |
+--------------+-------------------+ |
| 425 |
| Columns with | automatic widths. | |
| 426 |
+--------------+-------------------+ |
| 427 |
""", |
| 428 |
"""\ |
| 429 |
<document source="test data"> |
| 430 |
<table classes="colwidths-auto"> |
| 431 |
<tgroup cols="2"> |
| 432 |
<colspec colwidth="14"> |
| 433 |
<colspec colwidth="19"> |
| 434 |
<tbody> |
| 435 |
<row> |
| 436 |
<entry> |
| 437 |
<paragraph> |
| 438 |
Columns with |
| 439 |
<entry> |
| 440 |
<paragraph> |
| 441 |
automatic widths. |
| 442 |
"""], |
| 443 |
["""\ |
| 444 |
.. table:: |
| 445 |
:widths: grid |
| 446 |
|
| 447 |
+--------------+-------------------+ |
| 448 |
| Columns with | automatic widths. | |
| 449 |
+--------------+-------------------+ |
| 450 |
""", |
| 451 |
"""\ |
| 452 |
<document source="test data"> |
| 453 |
<table classes="colwidths-given"> |
| 454 |
<tgroup cols="2"> |
| 455 |
<colspec colwidth="14"> |
| 456 |
<colspec colwidth="19"> |
| 457 |
<tbody> |
| 458 |
<row> |
| 459 |
<entry> |
| 460 |
<paragraph> |
| 461 |
Columns with |
| 462 |
<entry> |
| 463 |
<paragraph> |
| 464 |
automatic widths. |
| 465 |
"""], |
| 466 |
["""\ |
| 467 |
.. table:: |
| 468 |
:align: center |
| 469 |
|
| 470 |
====== ===== |
| 471 |
Simple table |
| 472 |
====== ===== |
| 473 |
""", |
| 474 |
"""\ |
| 475 |
<document source="test data"> |
| 476 |
<table align="center"> |
| 477 |
<tgroup cols="2"> |
| 478 |
<colspec colwidth="6"> |
| 479 |
<colspec colwidth="5"> |
| 480 |
<tbody> |
| 481 |
<row> |
| 482 |
<entry> |
| 483 |
<paragraph> |
| 484 |
Simple |
| 485 |
<entry> |
| 486 |
<paragraph> |
| 487 |
table |
| 488 |
"""], |
| 489 |
] |
| 490 |
|
| 491 |
totest['csv_table'] = [ |
| 492 |
["""\ |
| 493 |
.. csv-table:: inline with integral header |
| 494 |
:width: 80% |
| 495 |
:widths: 10, 20, 30 |
| 496 |
:header-rows: 1 |
| 497 |
:stub-columns: 1 |
| 498 |
|
| 499 |
"Treat", "Quantity", "Description" |
| 500 |
"Albatross", 2.99, "On a stick!" |
| 501 |
"Crunchy Frog", 1.49, "If we took the bones out, it wouldn\'t be |
| 502 |
crunchy, now would it?" |
| 503 |
"Gannet Ripple", 1.99, "On a stick!" |
| 504 |
""", |
| 505 |
"""\ |
| 506 |
<document source="test data"> |
| 507 |
<table classes="colwidths-given" width="80%"> |
| 508 |
<title> |
| 509 |
inline with integral header |
| 510 |
<tgroup cols="3"> |
| 511 |
<colspec colwidth="10" stub="1"> |
| 512 |
<colspec colwidth="20"> |
| 513 |
<colspec colwidth="30"> |
| 514 |
<thead> |
| 515 |
<row> |
| 516 |
<entry> |
| 517 |
<paragraph> |
| 518 |
Treat |
| 519 |
<entry> |
| 520 |
<paragraph> |
| 521 |
Quantity |
| 522 |
<entry> |
| 523 |
<paragraph> |
| 524 |
Description |
| 525 |
<tbody> |
| 526 |
<row> |
| 527 |
<entry> |
| 528 |
<paragraph> |
| 529 |
Albatross |
| 530 |
<entry> |
| 531 |
<paragraph> |
| 532 |
2.99 |
| 533 |
<entry> |
| 534 |
<paragraph> |
| 535 |
On a stick! |
| 536 |
<row> |
| 537 |
<entry> |
| 538 |
<paragraph> |
| 539 |
Crunchy Frog |
| 540 |
<entry> |
| 541 |
<paragraph> |
| 542 |
1.49 |
| 543 |
<entry> |
| 544 |
<paragraph> |
| 545 |
If we took the bones out, it wouldn't be |
| 546 |
crunchy, now would it? |
| 547 |
<row> |
| 548 |
<entry> |
| 549 |
<paragraph> |
| 550 |
Gannet Ripple |
| 551 |
<entry> |
| 552 |
<paragraph> |
| 553 |
1.99 |
| 554 |
<entry> |
| 555 |
<paragraph> |
| 556 |
On a stick! |
| 557 |
"""], |
| 558 |
["""\ |
| 559 |
.. csv-table:: inline with separate header |
| 560 |
:delim: space |
| 561 |
:header: "Treat" Quantity "Description" |
| 562 |
:widths: 10,20,30 |
| 563 |
|
| 564 |
"Albatross" 2.99 "On a stick!" |
| 565 |
""", |
| 566 |
"""\ |
| 567 |
<document source="test data"> |
| 568 |
<table classes="colwidths-given"> |
| 569 |
<title> |
| 570 |
inline with separate header |
| 571 |
<tgroup cols="3"> |
| 572 |
<colspec colwidth="10"> |
| 573 |
<colspec colwidth="20"> |
| 574 |
<colspec colwidth="30"> |
| 575 |
<thead> |
| 576 |
<row> |
| 577 |
<entry> |
| 578 |
<paragraph> |
| 579 |
Treat |
| 580 |
<entry> |
| 581 |
<paragraph> |
| 582 |
Quantity |
| 583 |
<entry> |
| 584 |
<paragraph> |
| 585 |
Description |
| 586 |
<tbody> |
| 587 |
<row> |
| 588 |
<entry> |
| 589 |
<paragraph> |
| 590 |
Albatross |
| 591 |
<entry> |
| 592 |
<paragraph> |
| 593 |
2.99 |
| 594 |
<entry> |
| 595 |
<paragraph> |
| 596 |
On a stick! |
| 597 |
"""], |
| 598 |
["""\ |
| 599 |
.. csv-table:: complex internal structure |
| 600 |
:header: "Treat", Quantity, " |
| 601 |
* Description, |
| 602 |
* Definition, or |
| 603 |
* Narrative" |
| 604 |
|
| 605 |
" |
| 606 |
* Ice cream |
| 607 |
* Sorbet |
| 608 |
* Albatross", 2.99, "On a stick!" |
| 609 |
""", |
| 610 |
"""\ |
| 611 |
<document source="test data"> |
| 612 |
<table> |
| 613 |
<title> |
| 614 |
complex internal structure |
| 615 |
<tgroup cols="3"> |
| 616 |
<colspec colwidth="33"> |
| 617 |
<colspec colwidth="33"> |
| 618 |
<colspec colwidth="33"> |
| 619 |
<thead> |
| 620 |
<row> |
| 621 |
<entry> |
| 622 |
<paragraph> |
| 623 |
Treat |
| 624 |
<entry> |
| 625 |
<paragraph> |
| 626 |
Quantity |
| 627 |
<entry> |
| 628 |
<bullet_list bullet="*"> |
| 629 |
<list_item> |
| 630 |
<paragraph> |
| 631 |
Description, |
| 632 |
<list_item> |
| 633 |
<paragraph> |
| 634 |
Definition, or |
| 635 |
<list_item> |
| 636 |
<paragraph> |
| 637 |
Narrative |
| 638 |
<tbody> |
| 639 |
<row> |
| 640 |
<entry> |
| 641 |
<bullet_list bullet="*"> |
| 642 |
<list_item> |
| 643 |
<paragraph> |
| 644 |
Ice cream |
| 645 |
<list_item> |
| 646 |
<paragraph> |
| 647 |
Sorbet |
| 648 |
<list_item> |
| 649 |
<paragraph> |
| 650 |
Albatross |
| 651 |
<entry> |
| 652 |
<paragraph> |
| 653 |
2.99 |
| 654 |
<entry> |
| 655 |
<paragraph> |
| 656 |
On a stick! |
| 657 |
"""], |
| 658 |
["""\ |
| 659 |
.. csv-table:: short rows |
| 660 |
|
| 661 |
one, 2, three |
| 662 |
4, five |
| 663 |
""", |
| 664 |
"""\ |
| 665 |
<document source="test data"> |
| 666 |
<table> |
| 667 |
<title> |
| 668 |
short rows |
| 669 |
<tgroup cols="3"> |
| 670 |
<colspec colwidth="33"> |
| 671 |
<colspec colwidth="33"> |
| 672 |
<colspec colwidth="33"> |
| 673 |
<tbody> |
| 674 |
<row> |
| 675 |
<entry> |
| 676 |
<paragraph> |
| 677 |
one |
| 678 |
<entry> |
| 679 |
<paragraph> |
| 680 |
2 |
| 681 |
<entry> |
| 682 |
<paragraph> |
| 683 |
three |
| 684 |
<row> |
| 685 |
<entry> |
| 686 |
<paragraph> |
| 687 |
4 |
| 688 |
<entry> |
| 689 |
<paragraph> |
| 690 |
five |
| 691 |
<entry> |
| 692 |
"""], |
| 693 |
["""\ |
| 694 |
.. csv-table:: short rows |
| 695 |
:header-rows: 1 |
| 696 |
|
| 697 |
header col 1, header col 2 |
| 698 |
one, 2, three |
| 699 |
4 |
| 700 |
""", |
| 701 |
"""\ |
| 702 |
<document source="test data"> |
| 703 |
<table> |
| 704 |
<title> |
| 705 |
short rows |
| 706 |
<tgroup cols="3"> |
| 707 |
<colspec colwidth="33"> |
| 708 |
<colspec colwidth="33"> |
| 709 |
<colspec colwidth="33"> |
| 710 |
<thead> |
| 711 |
<row> |
| 712 |
<entry> |
| 713 |
<paragraph> |
| 714 |
header col 1 |
| 715 |
<entry> |
| 716 |
<paragraph> |
| 717 |
header col 2 |
| 718 |
<entry> |
| 719 |
<tbody> |
| 720 |
<row> |
| 721 |
<entry> |
| 722 |
<paragraph> |
| 723 |
one |
| 724 |
<entry> |
| 725 |
<paragraph> |
| 726 |
2 |
| 727 |
<entry> |
| 728 |
<paragraph> |
| 729 |
three |
| 730 |
<row> |
| 731 |
<entry> |
| 732 |
<paragraph> |
| 733 |
4 |
| 734 |
<entry> |
| 735 |
<entry> |
| 736 |
"""], |
| 737 |
["""\ |
| 738 |
.. csv-table:: non-ASCII characters |
| 739 |
|
| 740 |
Heiz\xf6lr\xfccksto\xdfabd\xe4mpfung |
| 741 |
""", |
| 742 |
"""\ |
| 743 |
<document source="test data"> |
| 744 |
<table> |
| 745 |
<title> |
| 746 |
non-ASCII characters |
| 747 |
<tgroup cols="1"> |
| 748 |
<colspec colwidth="100"> |
| 749 |
<tbody> |
| 750 |
<row> |
| 751 |
<entry> |
| 752 |
<paragraph> |
| 753 |
Heiz\xf6lr\xfccksto\xdfabd\xe4mpfung |
| 754 |
"""], |
| 755 |
["""\ |
| 756 |
.. csv-table:: center aligned |
| 757 |
:align: center |
| 758 |
|
| 759 |
11, 12 |
| 760 |
21, 22 |
| 761 |
""", |
| 762 |
"""\ |
| 763 |
<document source="test data"> |
| 764 |
<table align="center"> |
| 765 |
<title> |
| 766 |
center aligned |
| 767 |
<tgroup cols="2"> |
| 768 |
<colspec colwidth="50"> |
| 769 |
<colspec colwidth="50"> |
| 770 |
<tbody> |
| 771 |
<row> |
| 772 |
<entry> |
| 773 |
<paragraph> |
| 774 |
11 |
| 775 |
<entry> |
| 776 |
<paragraph> |
| 777 |
12 |
| 778 |
<row> |
| 779 |
<entry> |
| 780 |
<paragraph> |
| 781 |
21 |
| 782 |
<entry> |
| 783 |
<paragraph> |
| 784 |
22 |
| 785 |
"""], |
| 786 |
["""\ |
| 787 |
.. csv-table:: empty |
| 788 |
""", |
| 789 |
"""\ |
| 790 |
<document source="test data"> |
| 791 |
<system_message level="2" line="1" source="test data" type="WARNING"> |
| 792 |
<paragraph> |
| 793 |
The "csv-table" directive requires content; none supplied. |
| 794 |
<literal_block xml:space="preserve"> |
| 795 |
.. csv-table:: empty |
| 796 |
"""], |
| 797 |
["""\ |
| 798 |
.. csv-table:: insufficient header row data |
| 799 |
:header-rows: 2 |
| 800 |
|
| 801 |
some, csv, data |
| 802 |
""", |
| 803 |
"""\ |
| 804 |
<document source="test data"> |
| 805 |
<system_message level="3" line="1" source="test data" type="ERROR"> |
| 806 |
<paragraph> |
| 807 |
2 header row(s) specified but only 1 row(s) of data supplied ("csv-table" directive). |
| 808 |
<literal_block xml:space="preserve"> |
| 809 |
.. csv-table:: insufficient header row data |
| 810 |
:header-rows: 2 |
| 811 |
\n\ |
| 812 |
some, csv, data |
| 813 |
"""], |
| 814 |
["""\ |
| 815 |
.. csv-table:: insufficient body data |
| 816 |
:header-rows: 1 |
| 817 |
|
| 818 |
some, csv, data |
| 819 |
""", |
| 820 |
"""\ |
| 821 |
<document source="test data"> |
| 822 |
<system_message level="3" line="1" source="test data" type="ERROR"> |
| 823 |
<paragraph> |
| 824 |
Insufficient data supplied (1 row(s)); no data remaining for table body, required by "csv-table" directive. |
| 825 |
<literal_block xml:space="preserve"> |
| 826 |
.. csv-table:: insufficient body data |
| 827 |
:header-rows: 1 |
| 828 |
\n\ |
| 829 |
some, csv, data |
| 830 |
"""], |
| 831 |
["""\ |
| 832 |
.. csv-table:: content and external |
| 833 |
:file: bogus.csv |
| 834 |
|
| 835 |
some, csv, data |
| 836 |
""", |
| 837 |
"""\ |
| 838 |
<document source="test data"> |
| 839 |
<system_message level="3" line="1" source="test data" type="ERROR"> |
| 840 |
<paragraph> |
| 841 |
"csv-table" directive may not both specify an external file and have content. |
| 842 |
<literal_block xml:space="preserve"> |
| 843 |
.. csv-table:: content and external |
| 844 |
:file: bogus.csv |
| 845 |
\n\ |
| 846 |
some, csv, data |
| 847 |
"""], |
| 848 |
["""\ |
| 849 |
.. csv-table:: external file and url |
| 850 |
:file: bogus.csv |
| 851 |
:url: http://example.org/bogus.csv |
| 852 |
""", |
| 853 |
"""\ |
| 854 |
<document source="test data"> |
| 855 |
<system_message level="3" line="1" source="test data" type="ERROR"> |
| 856 |
<paragraph> |
| 857 |
The "file" and "url" options may not be simultaneously specified for the "csv-table" directive. |
| 858 |
<literal_block xml:space="preserve"> |
| 859 |
.. csv-table:: external file and url |
| 860 |
:file: bogus.csv |
| 861 |
:url: http://example.org/bogus.csv |
| 862 |
"""], |
| 863 |
["""\ |
| 864 |
.. csv-table:: error in the *title |
| 865 |
|
| 866 |
some, csv, data |
| 867 |
""", |
| 868 |
"""\ |
| 869 |
<document source="test data"> |
| 870 |
<table> |
| 871 |
<title> |
| 872 |
error in the \n\ |
| 873 |
<problematic ids="problematic-1" refid="system-message-1"> |
| 874 |
* |
| 875 |
title |
| 876 |
<tgroup cols="3"> |
| 877 |
<colspec colwidth="33"> |
| 878 |
<colspec colwidth="33"> |
| 879 |
<colspec colwidth="33"> |
| 880 |
<tbody> |
| 881 |
<row> |
| 882 |
<entry> |
| 883 |
<paragraph> |
| 884 |
some |
| 885 |
<entry> |
| 886 |
<paragraph> |
| 887 |
csv |
| 888 |
<entry> |
| 889 |
<paragraph> |
| 890 |
data |
| 891 |
<system_message backrefs="problematic-1" ids="system-message-1" level="2" line="1" source="test data" type="WARNING"> |
| 892 |
<paragraph> |
| 893 |
Inline emphasis start-string without end-string. |
| 894 |
"""], |
| 895 |
["""\ |
| 896 |
.. csv-table:: no such file |
| 897 |
:file: bogus.csv |
| 898 |
""", |
| 899 |
"""\ |
| 900 |
<document source="test data"> |
| 901 |
<system_message level="4" line="1" source="test data" type="SEVERE"> |
| 902 |
<paragraph> |
| 903 |
Problems with "csv-table" directive path: |
| 904 |
[Errno 2] No such file or directory: 'bogus.csv'. |
| 905 |
<literal_block xml:space="preserve"> |
| 906 |
.. csv-table:: no such file |
| 907 |
:file: bogus.csv |
| 908 |
"""], |
| 909 |
|
| 910 |
["""\ |
| 911 |
.. csv-table:: bad URL |
| 912 |
:url: bogus.csv |
| 913 |
""", |
| 914 |
"""\ |
| 915 |
<document source="test data"> |
| 916 |
<system_message level="4" line="1" source="test data" type="SEVERE"> |
| 917 |
<paragraph> |
| 918 |
Problems with "csv-table" directive URL "bogus.csv": |
| 919 |
unknown url type: 'bogus.csv'. |
| 920 |
<literal_block xml:space="preserve"> |
| 921 |
.. csv-table:: bad URL |
| 922 |
:url: bogus.csv |
| 923 |
"""], |
| 924 |
["""\ |
| 925 |
.. csv-table:: column mismatch |
| 926 |
:widths: 10,20 |
| 927 |
|
| 928 |
some, csv, data |
| 929 |
""", |
| 930 |
"""\ |
| 931 |
<document source="test data"> |
| 932 |
<system_message level="3" line="1" source="test data" type="ERROR"> |
| 933 |
<paragraph> |
| 934 |
"csv-table" widths do not match the number of columns in table (3). |
| 935 |
<literal_block xml:space="preserve"> |
| 936 |
.. csv-table:: column mismatch |
| 937 |
:widths: 10,20 |
| 938 |
\n\ |
| 939 |
some, csv, data |
| 940 |
"""], |
| 941 |
["""\ |
| 942 |
.. csv-table:: bad column widths |
| 943 |
:widths: 10,y,z |
| 944 |
|
| 945 |
some, csv, data |
| 946 |
|
| 947 |
.. csv-table:: bad column widths |
| 948 |
:widths: 0 0 0 |
| 949 |
|
| 950 |
some, csv, data |
| 951 |
""", |
| 952 |
"""\ |
| 953 |
<document source="test data"> |
| 954 |
<system_message level="3" line="1" source="test data" type="ERROR"> |
| 955 |
<paragraph> |
| 956 |
Error in "csv-table" directive: |
| 957 |
invalid option value: (option: "widths"; value: '10,y,z') |
| 958 |
%s. |
| 959 |
<literal_block xml:space="preserve"> |
| 960 |
.. csv-table:: bad column widths |
| 961 |
:widths: 10,y,z |
| 962 |
\n\ |
| 963 |
some, csv, data |
| 964 |
<system_message level="3" line="6" source="test data" type="ERROR"> |
| 965 |
<paragraph> |
| 966 |
Error in "csv-table" directive: |
| 967 |
invalid option value: (option: "widths"; value: '0 0 0') |
| 968 |
negative or zero value; must be positive. |
| 969 |
<literal_block xml:space="preserve"> |
| 970 |
.. csv-table:: bad column widths |
| 971 |
:widths: 0 0 0 |
| 972 |
\n\ |
| 973 |
some, csv, data |
| 974 |
""" % invalid_literal], |
| 975 |
["""\ |
| 976 |
.. csv-table:: good delimiter |
| 977 |
:delim: / |
| 978 |
|
| 979 |
some/csv/data |
| 980 |
|
| 981 |
.. csv-table:: good delimiter |
| 982 |
:delim: \\ |
| 983 |
|
| 984 |
some\\csv\\data |
| 985 |
|
| 986 |
.. csv-table:: good delimiter |
| 987 |
:delim: 0x5c |
| 988 |
|
| 989 |
some\\csv\\data |
| 990 |
|
| 991 |
.. csv-table:: good delimiter |
| 992 |
:delim: space |
| 993 |
|
| 994 |
some csv data |
| 995 |
""", |
| 996 |
"""\ |
| 997 |
<document source="test data"> |
| 998 |
<table> |
| 999 |
<title> |
| 1000 |
good delimiter |
| 1001 |
<tgroup cols="3"> |
| 1002 |
<colspec colwidth="33"> |
| 1003 |
<colspec colwidth="33"> |
| 1004 |
<colspec colwidth="33"> |
| 1005 |
<tbody> |
| 1006 |
<row> |
| 1007 |
<entry> |
| 1008 |
<paragraph> |
| 1009 |
some |
| 1010 |
<entry> |
| 1011 |
<paragraph> |
| 1012 |
csv |
| 1013 |
<entry> |
| 1014 |
<paragraph> |
| 1015 |
data |
| 1016 |
<table> |
| 1017 |
<title> |
| 1018 |
good delimiter |
| 1019 |
<tgroup cols="3"> |
| 1020 |
<colspec colwidth="33"> |
| 1021 |
<colspec colwidth="33"> |
| 1022 |
<colspec colwidth="33"> |
| 1023 |
<tbody> |
| 1024 |
<row> |
| 1025 |
<entry> |
| 1026 |
<paragraph> |
| 1027 |
some |
| 1028 |
<entry> |
| 1029 |
<paragraph> |
| 1030 |
csv |
| 1031 |
<entry> |
| 1032 |
<paragraph> |
| 1033 |
data |
| 1034 |
<table> |
| 1035 |
<title> |
| 1036 |
good delimiter |
| 1037 |
<tgroup cols="3"> |
| 1038 |
<colspec colwidth="33"> |
| 1039 |
<colspec colwidth="33"> |
| 1040 |
<colspec colwidth="33"> |
| 1041 |
<tbody> |
| 1042 |
<row> |
| 1043 |
<entry> |
| 1044 |
<paragraph> |
| 1045 |
some |
| 1046 |
<entry> |
| 1047 |
<paragraph> |
| 1048 |
csv |
| 1049 |
<entry> |
| 1050 |
<paragraph> |
| 1051 |
data |
| 1052 |
<table> |
| 1053 |
<title> |
| 1054 |
good delimiter |
| 1055 |
<tgroup cols="3"> |
| 1056 |
<colspec colwidth="33"> |
| 1057 |
<colspec colwidth="33"> |
| 1058 |
<colspec colwidth="33"> |
| 1059 |
<tbody> |
| 1060 |
<row> |
| 1061 |
<entry> |
| 1062 |
<paragraph> |
| 1063 |
some |
| 1064 |
<entry> |
| 1065 |
<paragraph> |
| 1066 |
csv |
| 1067 |
<entry> |
| 1068 |
<paragraph> |
| 1069 |
data |
| 1070 |
"""], |
| 1071 |
["""\ |
| 1072 |
.. csv-table:: bad delimiter |
| 1073 |
:delim: multiple |
| 1074 |
|
| 1075 |
.. csv-table:: bad delimiter |
| 1076 |
:delim: U+9999999999999 |
| 1077 |
""", |
| 1078 |
"""\ |
| 1079 |
<document source="test data"> |
| 1080 |
<system_message level="3" line="1" source="test data" type="ERROR"> |
| 1081 |
<paragraph> |
| 1082 |
Error in "csv-table" directive: |
| 1083 |
invalid option value: (option: "delim"; value: 'multiple') |
| 1084 |
'multiple' invalid; must be a single character or a Unicode code. |
| 1085 |
<literal_block xml:space="preserve"> |
| 1086 |
.. csv-table:: bad delimiter |
| 1087 |
:delim: multiple |
| 1088 |
<system_message level="3" line="4" source="test data" type="ERROR"> |
| 1089 |
<paragraph> |
| 1090 |
Error in "csv-table" directive: |
| 1091 |
invalid option value: (option: "delim"; value: 'U+9999999999999') |
| 1092 |
%s. |
| 1093 |
<literal_block xml:space="preserve"> |
| 1094 |
.. csv-table:: bad delimiter |
| 1095 |
:delim: U+9999999999999 |
| 1096 |
""" % unichr_exception_string], |
| 1097 |
["""\ |
| 1098 |
.. csv-table:: bad CSV data |
| 1099 |
|
| 1100 |
"bad", "csv, data |
| 1101 |
""", |
| 1102 |
"""\ |
| 1103 |
<document source="test data"> |
| 1104 |
<system_message level="3" line="1" source="test data" type="ERROR"> |
| 1105 |
<paragraph> |
| 1106 |
Error with CSV data in "csv-table" directive: |
| 1107 |
%s |
| 1108 |
<literal_block xml:space="preserve"> |
| 1109 |
.. csv-table:: bad CSV data |
| 1110 |
\n\ |
| 1111 |
"bad", \"csv, data |
| 1112 |
""" % csv_eod_error_str], |
| 1113 |
["""\ |
| 1114 |
.. csv-table:: bad CSV header data |
| 1115 |
:header: "bad", "csv, data |
| 1116 |
|
| 1117 |
good, csv, data |
| 1118 |
""", |
| 1119 |
"""\ |
| 1120 |
<document source="test data"> |
| 1121 |
<system_message level="3" line="1" source="test data" type="ERROR"> |
| 1122 |
<paragraph> |
| 1123 |
Error with CSV data in "csv-table" directive: |
| 1124 |
%s |
| 1125 |
<literal_block xml:space="preserve"> |
| 1126 |
.. csv-table:: bad CSV header data |
| 1127 |
:header: "bad", \"csv, data |
| 1128 |
\n\ |
| 1129 |
good, csv, data |
| 1130 |
""" % csv_eod_error_str], |
| 1131 |
["""\ |
| 1132 |
.. csv-table:: bad encoding |
| 1133 |
:file: %s |
| 1134 |
:encoding: latin-1 |
| 1135 |
|
| 1136 |
(7- and 8-bit text encoded as UTF-16 has lots of null/zero bytes.) |
| 1137 |
""" % utf_16_csv, |
| 1138 |
bad_encoding_result |
| 1139 |
], |
| 1140 |
["""\ |
| 1141 |
.. csv-table:: good encoding |
| 1142 |
:file: %s |
| 1143 |
:encoding: utf-16 |
| 1144 |
:header-rows: 1 |
| 1145 |
""" % utf_16_csv, |
| 1146 |
"""\ |
| 1147 |
<document source="test data"> |
| 1148 |
<table> |
| 1149 |
<title> |
| 1150 |
good encoding |
| 1151 |
<tgroup cols="3"> |
| 1152 |
<colspec colwidth="33"> |
| 1153 |
<colspec colwidth="33"> |
| 1154 |
<colspec colwidth="33"> |
| 1155 |
<thead> |
| 1156 |
<row> |
| 1157 |
<entry> |
| 1158 |
<paragraph> |
| 1159 |
Treat |
| 1160 |
<entry> |
| 1161 |
<paragraph> |
| 1162 |
Quantity |
| 1163 |
<entry> |
| 1164 |
<paragraph> |
| 1165 |
Description |
| 1166 |
<tbody> |
| 1167 |
<row> |
| 1168 |
<entry> |
| 1169 |
<paragraph> |
| 1170 |
Albatr\u00b0\u00df |
| 1171 |
<entry> |
| 1172 |
<paragraph> |
| 1173 |
2.99 |
| 1174 |
<entry> |
| 1175 |
<paragraph> |
| 1176 |
\u00a1On a \u03c3\u03c4\u03b9\u03ba! |
| 1177 |
<row> |
| 1178 |
<entry> |
| 1179 |
<paragraph> |
| 1180 |
Crunchy Frog |
| 1181 |
<entry> |
| 1182 |
<paragraph> |
| 1183 |
1.49 |
| 1184 |
<entry> |
| 1185 |
<paragraph> |
| 1186 |
If we took the b\u00f6nes out, it wouldn\u2019t be |
| 1187 |
crunchy, now would it? |
| 1188 |
<row> |
| 1189 |
<entry> |
| 1190 |
<paragraph> |
| 1191 |
Gannet Ripple |
| 1192 |
<entry> |
| 1193 |
<paragraph> |
| 1194 |
1.99 |
| 1195 |
<entry> |
| 1196 |
<paragraph> |
| 1197 |
\u00bfOn a \u03c3\u03c4\u03b9\u03ba? |
| 1198 |
"""], |
| 1199 |
["""\ |
| 1200 |
.. csv-table:: no CSV data |
| 1201 |
:file: %s |
| 1202 |
""" % empty_txt, |
| 1203 |
"""\ |
| 1204 |
<document source="test data"> |
| 1205 |
<system_message level="3" line="1" source="test data" type="ERROR"> |
| 1206 |
<paragraph> |
| 1207 |
No table data detected in CSV file. |
| 1208 |
<literal_block xml:space="preserve"> |
| 1209 |
.. csv-table:: no CSV data |
| 1210 |
:file: %s |
| 1211 |
""" % empty_txt], |
| 1212 |
] |
| 1213 |
|
| 1214 |
totest['list_table'] = [ |
| 1215 |
["""\ |
| 1216 |
.. list-table:: list table with integral header |
| 1217 |
:widths: 10 20 30 |
| 1218 |
:header-rows: 1 |
| 1219 |
:stub-columns: 1 |
| 1220 |
|
| 1221 |
* - Treat |
| 1222 |
- Quantity |
| 1223 |
- Description |
| 1224 |
* - Albatross |
| 1225 |
- 2.99 |
| 1226 |
- On a stick! |
| 1227 |
* - Crunchy Frog |
| 1228 |
- 1.49 |
| 1229 |
- If we took the bones out, it wouldn\'t be |
| 1230 |
crunchy, now would it? |
| 1231 |
* - Gannet Ripple |
| 1232 |
- 1.99 |
| 1233 |
- On a stick! |
| 1234 |
""", |
| 1235 |
"""\ |
| 1236 |
<document source="test data"> |
| 1237 |
<table classes="colwidths-given"> |
| 1238 |
<title> |
| 1239 |
list table with integral header |
| 1240 |
<tgroup cols="3"> |
| 1241 |
<colspec colwidth="10" stub="1"> |
| 1242 |
<colspec colwidth="20"> |
| 1243 |
<colspec colwidth="30"> |
| 1244 |
<thead> |
| 1245 |
<row> |
| 1246 |
<entry> |
| 1247 |
<paragraph> |
| 1248 |
Treat |
| 1249 |
<entry> |
| 1250 |
<paragraph> |
| 1251 |
Quantity |
| 1252 |
<entry> |
| 1253 |
<paragraph> |
| 1254 |
Description |
| 1255 |
<tbody> |
| 1256 |
<row> |
| 1257 |
<entry> |
| 1258 |
<paragraph> |
| 1259 |
Albatross |
| 1260 |
<entry> |
| 1261 |
<paragraph> |
| 1262 |
2.99 |
| 1263 |
<entry> |
| 1264 |
<paragraph> |
| 1265 |
On a stick! |
| 1266 |
<row> |
| 1267 |
<entry> |
| 1268 |
<paragraph> |
| 1269 |
Crunchy Frog |
| 1270 |
<entry> |
| 1271 |
<paragraph> |
| 1272 |
1.49 |
| 1273 |
<entry> |
| 1274 |
<paragraph> |
| 1275 |
If we took the bones out, it wouldn\'t be |
| 1276 |
crunchy, now would it? |
| 1277 |
<row> |
| 1278 |
<entry> |
| 1279 |
<paragraph> |
| 1280 |
Gannet Ripple |
| 1281 |
<entry> |
| 1282 |
<paragraph> |
| 1283 |
1.99 |
| 1284 |
<entry> |
| 1285 |
<paragraph> |
| 1286 |
On a stick! |
| 1287 |
"""], |
| 1288 |
["""\ |
| 1289 |
.. list-table:: list table with integral header |
| 1290 |
:widths: auto |
| 1291 |
:header-rows: 1 |
| 1292 |
:stub-columns: 1 |
| 1293 |
|
| 1294 |
* - Treat |
| 1295 |
- Quantity |
| 1296 |
- Description |
| 1297 |
* - Albatross |
| 1298 |
- 2.99 |
| 1299 |
- On a stick! |
| 1300 |
""", |
| 1301 |
"""\ |
| 1302 |
<document source="test data"> |
| 1303 |
<table classes="colwidths-auto"> |
| 1304 |
<title> |
| 1305 |
list table with integral header |
| 1306 |
<tgroup cols="3"> |
| 1307 |
<colspec colwidth="33" stub="1"> |
| 1308 |
<colspec colwidth="33"> |
| 1309 |
<colspec colwidth="33"> |
| 1310 |
<thead> |
| 1311 |
<row> |
| 1312 |
<entry> |
| 1313 |
<paragraph> |
| 1314 |
Treat |
| 1315 |
<entry> |
| 1316 |
<paragraph> |
| 1317 |
Quantity |
| 1318 |
<entry> |
| 1319 |
<paragraph> |
| 1320 |
Description |
| 1321 |
<tbody> |
| 1322 |
<row> |
| 1323 |
<entry> |
| 1324 |
<paragraph> |
| 1325 |
Albatross |
| 1326 |
<entry> |
| 1327 |
<paragraph> |
| 1328 |
2.99 |
| 1329 |
<entry> |
| 1330 |
<paragraph> |
| 1331 |
On a stick! |
| 1332 |
"""], |
| 1333 |
["""\ |
| 1334 |
.. list-table:: list table with integral header |
| 1335 |
:header-rows: 1 |
| 1336 |
:stub-columns: 1 |
| 1337 |
|
| 1338 |
* - Treat |
| 1339 |
- Quantity |
| 1340 |
- Description |
| 1341 |
* - Albatross |
| 1342 |
- 2.99 |
| 1343 |
- On a stick! |
| 1344 |
* - Crunchy Frog |
| 1345 |
- 1.49 |
| 1346 |
- If we took the bones out, it wouldn\'t be |
| 1347 |
crunchy, now would it? |
| 1348 |
* - Gannet Ripple |
| 1349 |
- 1.99 |
| 1350 |
- On a stick! |
| 1351 |
""", |
| 1352 |
"""\ |
| 1353 |
<document source="test data"> |
| 1354 |
<table> |
| 1355 |
<title> |
| 1356 |
list table with integral header |
| 1357 |
<tgroup cols="3"> |
| 1358 |
<colspec colwidth="33" stub="1"> |
| 1359 |
<colspec colwidth="33"> |
| 1360 |
<colspec colwidth="33"> |
| 1361 |
<thead> |
| 1362 |
<row> |
| 1363 |
<entry> |
| 1364 |
<paragraph> |
| 1365 |
Treat |
| 1366 |
<entry> |
| 1367 |
<paragraph> |
| 1368 |
Quantity |
| 1369 |
<entry> |
| 1370 |
<paragraph> |
| 1371 |
Description |
| 1372 |
<tbody> |
| 1373 |
<row> |
| 1374 |
<entry> |
| 1375 |
<paragraph> |
| 1376 |
Albatross |
| 1377 |
<entry> |
| 1378 |
<paragraph> |
| 1379 |
2.99 |
| 1380 |
<entry> |
| 1381 |
<paragraph> |
| 1382 |
On a stick! |
| 1383 |
<row> |
| 1384 |
<entry> |
| 1385 |
<paragraph> |
| 1386 |
Crunchy Frog |
| 1387 |
<entry> |
| 1388 |
<paragraph> |
| 1389 |
1.49 |
| 1390 |
<entry> |
| 1391 |
<paragraph> |
| 1392 |
If we took the bones out, it wouldn\'t be |
| 1393 |
crunchy, now would it? |
| 1394 |
<row> |
| 1395 |
<entry> |
| 1396 |
<paragraph> |
| 1397 |
Gannet Ripple |
| 1398 |
<entry> |
| 1399 |
<paragraph> |
| 1400 |
1.99 |
| 1401 |
<entry> |
| 1402 |
<paragraph> |
| 1403 |
On a stick! |
| 1404 |
"""], |
| 1405 |
["""\ |
| 1406 |
.. list-table:: center aligned |
| 1407 |
:align: center |
| 1408 |
|
| 1409 |
* - 11 |
| 1410 |
- 12 |
| 1411 |
* - 21 |
| 1412 |
- 22 |
| 1413 |
""", |
| 1414 |
"""\ |
| 1415 |
<document source="test data"> |
| 1416 |
<table align="center"> |
| 1417 |
<title> |
| 1418 |
center aligned |
| 1419 |
<tgroup cols="2"> |
| 1420 |
<colspec colwidth="50"> |
| 1421 |
<colspec colwidth="50"> |
| 1422 |
<tbody> |
| 1423 |
<row> |
| 1424 |
<entry> |
| 1425 |
<paragraph> |
| 1426 |
11 |
| 1427 |
<entry> |
| 1428 |
<paragraph> |
| 1429 |
12 |
| 1430 |
<row> |
| 1431 |
<entry> |
| 1432 |
<paragraph> |
| 1433 |
21 |
| 1434 |
<entry> |
| 1435 |
<paragraph> |
| 1436 |
22 |
| 1437 |
"""], |
| 1438 |
["""\ |
| 1439 |
.. list-table:: |
| 1440 |
|
| 1441 |
not a bullet list |
| 1442 |
""", |
| 1443 |
"""\ |
| 1444 |
<document source="test data"> |
| 1445 |
<system_message level="3" line="1" source="test data" type="ERROR"> |
| 1446 |
<paragraph> |
| 1447 |
Error parsing content block for the "list-table" directive: exactly one bullet list expected. |
| 1448 |
<literal_block xml:space="preserve"> |
| 1449 |
.. list-table:: |
| 1450 |
\n\ |
| 1451 |
not a bullet list |
| 1452 |
"""], |
| 1453 |
["""\ |
| 1454 |
.. list-table:: |
| 1455 |
|
| 1456 |
* not a second-level bullet list |
| 1457 |
""", |
| 1458 |
"""\ |
| 1459 |
<document source="test data"> |
| 1460 |
<system_message level="3" line="1" source="test data" type="ERROR"> |
| 1461 |
<paragraph> |
| 1462 |
Error parsing content block for the "list-table" directive: two-level bullet list expected, but row 1 does not contain a second-level bullet list. |
| 1463 |
<literal_block xml:space="preserve"> |
| 1464 |
.. list-table:: |
| 1465 |
\n\ |
| 1466 |
* not a second-level bullet list |
| 1467 |
"""], |
| 1468 |
["""\ |
| 1469 |
.. list-table:: |
| 1470 |
|
| 1471 |
* - columns not uniform |
| 1472 |
* - first row has one, |
| 1473 |
- second row has two |
| 1474 |
""", |
| 1475 |
"""\ |
| 1476 |
<document source="test data"> |
| 1477 |
<system_message level="3" line="1" source="test data" type="ERROR"> |
| 1478 |
<paragraph> |
| 1479 |
Error parsing content block for the "list-table" directive: uniform two-level bullet list expected, but row 2 does not contain the same number of items as row 1 (2 vs 1). |
| 1480 |
<literal_block xml:space="preserve"> |
| 1481 |
.. list-table:: |
| 1482 |
\n\ |
| 1483 |
* - columns not uniform |
| 1484 |
* - first row has one, |
| 1485 |
- second row has two |
| 1486 |
"""], |
| 1487 |
["""\ |
| 1488 |
.. list-table:: |
| 1489 |
:widths: 10 20 |
| 1490 |
|
| 1491 |
* - ":widths:" option doesn't match columns |
| 1492 |
""", |
| 1493 |
"""\ |
| 1494 |
<document source="test data"> |
| 1495 |
<system_message level="3" line="1" source="test data" type="ERROR"> |
| 1496 |
<paragraph> |
| 1497 |
"list-table" widths do not match the number of columns in table (1). |
| 1498 |
<literal_block xml:space="preserve"> |
| 1499 |
.. list-table:: |
| 1500 |
:widths: 10 20 |
| 1501 |
\n\ |
| 1502 |
* - ":widths:" option doesn\'t match columns |
| 1503 |
"""], |
| 1504 |
["""\ |
| 1505 |
.. list-table:: |
| 1506 |
:stub-columns: 3 |
| 1507 |
|
| 1508 |
* - column 1 |
| 1509 |
- column 2 |
| 1510 |
""", |
| 1511 |
"""\ |
| 1512 |
<document source="test data"> |
| 1513 |
<system_message level="3" line="1" source="test data" type="ERROR"> |
| 1514 |
<paragraph> |
| 1515 |
3 stub column(s) specified but only 2 columns(s) of data supplied ("list-table" directive). |
| 1516 |
<literal_block xml:space="preserve"> |
| 1517 |
.. list-table:: |
| 1518 |
:stub-columns: 3 |
| 1519 |
\n\ |
| 1520 |
* - column 1 |
| 1521 |
- column 2 |
| 1522 |
"""], |
| 1523 |
["""\ |
| 1524 |
.. list-table:: |
| 1525 |
:stub-columns: 2 |
| 1526 |
|
| 1527 |
* - column 1 |
| 1528 |
- column 2 |
| 1529 |
""", |
| 1530 |
"""\ |
| 1531 |
<document source="test data"> |
| 1532 |
<system_message level="3" line="1" source="test data" type="ERROR"> |
| 1533 |
<paragraph> |
| 1534 |
Insufficient data supplied (2 columns(s)); no data remaining for table body, required by "list-table" directive. |
| 1535 |
<literal_block xml:space="preserve"> |
| 1536 |
.. list-table:: |
| 1537 |
:stub-columns: 2 |
| 1538 |
\n\ |
| 1539 |
* - column 1 |
| 1540 |
- column 2 |
| 1541 |
"""], |
| 1542 |
["""\ |
| 1543 |
.. list-table:: empty |
| 1544 |
""", |
| 1545 |
"""\ |
| 1546 |
<document source="test data"> |
| 1547 |
<system_message level="3" line="1" source="test data" type="ERROR"> |
| 1548 |
<paragraph> |
| 1549 |
The "list-table" directive is empty; content required. |
| 1550 |
<literal_block xml:space="preserve"> |
| 1551 |
.. list-table:: empty |
| 1552 |
"""], |
| 1553 |
] |
| 1554 |
|
| 1555 |
|
| 1556 |
if __name__ == '__main__': |
| 1557 |
unittest.main() |