summaryrefslogtreecommitdiffstats
path: root/tests/test_renderers/test_myst_config.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_renderers/test_myst_config.py')
-rw-r--r--tests/test_renderers/test_myst_config.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/test_renderers/test_myst_config.py b/tests/test_renderers/test_myst_config.py
new file mode 100644
index 0000000..31e2444
--- /dev/null
+++ b/tests/test_renderers/test_myst_config.py
@@ -0,0 +1,38 @@
+"""Test (docutils) parsing with different ``MdParserConfig`` options set."""
+import shlex
+from io import StringIO
+from pathlib import Path
+
+import pytest
+from docutils.core import Publisher, publish_doctree
+
+from myst_parser.parsers.docutils_ import Parser
+
+FIXTURE_PATH = Path(__file__).parent.joinpath("fixtures")
+
+
+@pytest.mark.param_file(FIXTURE_PATH / "myst-config.txt")
+def test_cmdline(file_params):
+ """The description is parsed as a docutils commandline"""
+ pub = Publisher(parser=Parser())
+ option_parser = pub.setup_option_parser()
+ try:
+ settings = option_parser.parse_args(
+ shlex.split(file_params.description)
+ ).__dict__
+ except Exception as err:
+ raise AssertionError(
+ f"Failed to parse commandline: {file_params.description}\n{err}"
+ )
+ report_stream = StringIO()
+ settings["warning_stream"] = report_stream
+ doctree = publish_doctree(
+ file_params.content,
+ parser=Parser(),
+ settings_overrides=settings,
+ )
+ output = doctree.pformat()
+ warnings = report_stream.getvalue()
+ if warnings:
+ output += "\n" + warnings
+ file_params.assert_expected(output, rstrip_lines=True)