diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-29 04:23:02 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-29 04:23:02 +0000 |
commit | 943e3dc057eca53e68ddec51529bd6a1279ebd8e (patch) | |
tree | 61fb7bac619a56dfbcdcbdb7b0d4d6535fc36fe9 /tests/test_renderers/test_myst_refs.py | |
parent | Initial commit. (diff) | |
download | myst-parser-upstream.tar.xz myst-parser-upstream.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_renderers/test_myst_refs.py')
-rw-r--r-- | tests/test_renderers/test_myst_refs.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/test_renderers/test_myst_refs.py b/tests/test_renderers/test_myst_refs.py new file mode 100644 index 0000000..083b34a --- /dev/null +++ b/tests/test_renderers/test_myst_refs.py @@ -0,0 +1,38 @@ +import pytest +from sphinx_pytest.plugin import CreateDoctree + + +@pytest.mark.parametrize( + "test_name,text,should_warn", + [ + ("null", "", False), + ("missing", "[](ref)", True), + ("doc", "[](index)", False), + ("doc_with_extension", "[](index.md)", False), + ("doc_nested", "[*text*](index)", False), + ("ref", "(ref)=\n# Title\n[](ref)", False), + ("ref_nested", "(ref)=\n# Title\n[*text*](ref)", False), + ("duplicate", "(index)=\n# Title\n[](index)", True), + ("ref_colon", "(ref:colon)=\n# Title\n[](ref:colon)", False), + ], +) +def test_parse( + test_name: str, + text: str, + should_warn: bool, + sphinx_doctree: CreateDoctree, + file_regression, +): + sphinx_doctree.set_conf({"extensions": ["myst_parser"]}) + result = sphinx_doctree(text, "index.md") + assert not result.warnings + + doctree = result.get_resolved_doctree("index") + + if should_warn: + assert result.warnings + else: + assert not result.warnings + + doctree["source"] = "root/index.md" + file_regression.check(doctree.pformat(), basename=test_name, extension=".xml") |