| 1 |
|
| 2 |
|
| 3 |
e. |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
""" |
| 14 |
Tests for inline markup in docutils/parsers/rst/states.py. |
| 15 |
Interpreted text tests are in a separate module, test_interpreted.py. |
| 16 |
""" |
| 17 |
|
| 18 |
from pathlib import Path |
| 19 |
import sys |
| 20 |
import unittest |
| 21 |
|
| 22 |
if __name__ == '__main__': |
| 23 |
|
| 24 |
|
| 25 |
sys.path.insert(0, str(Path(__file__).resolve().parents[3])) |
| 26 |
|
| 27 |
from docutils.frontend import get_default_settings |
| 28 |
from docutils.parsers.recommonmark_wrapper import Parser |
| 29 |
from docutils.utils import new_document |
| 30 |
|
| 31 |
|
| 32 |
class RecommonmarkParserTestCase(unittest.TestCase): |
| 33 |
def test_parser(self): |
| 34 |
parser = Parser() |
| 35 |
settings = get_default_settings(Parser) |
| 36 |
settings.warning_stream = '' |
| 37 |
for name, cases in totest.items(): |
| 38 |
for casenum, (case_input, case_expected) in enumerate(cases): |
| 39 |
with self.subTest(id=f'totest[{name!r}][{casenum}]'): |
| 40 |
document = new_document('test data', settings.copy()) |
| 41 |
parser.parse(case_input, document) |
| 42 |
output = document.pformat() |
| 43 |
self.assertEqual(case_expected, output) |
| 44 |
|
| 45 |
|
| 46 |
totest = {} |
| 47 |
|
| 48 |
totest['default'] = [ |
| 49 |
["""\ |
| 50 |
within the limit |
| 51 |
%s |
| 52 |
""" % ("x"*10000), |
| 53 |
"""\ |
| 54 |
<document source="test data"> |
| 55 |
<paragraph> |
| 56 |
within the limit |
| 57 |
%s |
| 58 |
""" % ("x"*10000)], |
| 59 |
["""\ |
| 60 |
above the limit |
| 61 |
%s |
| 62 |
""" % ("x"*10001), |
| 63 |
"""\ |
| 64 |
<document source="test data"> |
| 65 |
<system_message level="3" source="test data" type="ERROR"> |
| 66 |
<paragraph> |
| 67 |
Line 2 exceeds the line-length-limit. |
| 68 |
"""], |
| 69 |
] |
| 70 |
|
| 71 |
|
| 72 |
if __name__ == '__main__': |
| 73 |
unittest.main() |