summaryrefslogtreecommitdiffstats
path: root/tests/test_html/test_html_to_nodes.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-29 04:23:02 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-29 04:23:02 +0000
commit943e3dc057eca53e68ddec51529bd6a1279ebd8e (patch)
tree61fb7bac619a56dfbcdcbdb7b0d4d6535fc36fe9 /tests/test_html/test_html_to_nodes.py
parentInitial commit. (diff)
downloadmyst-parser-upstream/0.18.1.tar.xz
myst-parser-upstream/0.18.1.zip
Adding upstream version 0.18.1.upstream/0.18.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_html/test_html_to_nodes.py')
-rw-r--r--tests/test_html/test_html_to_nodes.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/test_html/test_html_to_nodes.py b/tests/test_html/test_html_to_nodes.py
new file mode 100644
index 0000000..207a627
--- /dev/null
+++ b/tests/test_html/test_html_to_nodes.py
@@ -0,0 +1,35 @@
+from pathlib import Path
+from unittest.mock import Mock
+
+import pytest
+from docutils import nodes
+
+from myst_parser.config.main import MdParserConfig
+from myst_parser.mdit_to_docutils.html_to_nodes import html_to_nodes
+
+FIXTURE_PATH = Path(__file__).parent
+
+
+@pytest.fixture()
+def mock_renderer():
+ def _run_directive(name: str, first_line: str, content: str, position: int):
+ node = nodes.Element(name=name, first=first_line, position=position)
+ node += nodes.Text(content)
+ return [node]
+
+ return Mock(
+ md_config=MdParserConfig(enable_extensions=["html_image", "html_admonition"]),
+ document={"source": "source"},
+ reporter=Mock(
+ warning=Mock(return_value=nodes.system_message("warning")),
+ error=Mock(return_value=nodes.system_message("error")),
+ ),
+ run_directive=_run_directive,
+ )
+
+
+@pytest.mark.param_file(FIXTURE_PATH / "html_to_nodes.md")
+def test_html_to_nodes(file_params, mock_renderer):
+ output = nodes.container()
+ output += html_to_nodes(file_params.content, line_number=0, renderer=mock_renderer)
+ file_params.assert_expected(output.pformat(), rstrip=True)