diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-29 04:24:24 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-29 04:24:24 +0000 |
commit | 12e8343068b906f8b2afddc5569968a8a91fa5b0 (patch) | |
tree | 75cc5e05a4392ea0292251898f992a15a16b172b /tests/test_cmark_spec/test_spec.py | |
parent | Initial commit. (diff) | |
download | markdown-it-py-upstream.tar.xz markdown-it-py-upstream.zip |
Adding upstream version 2.1.0.upstream/2.1.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_cmark_spec/test_spec.py')
-rw-r--r-- | tests/test_cmark_spec/test_spec.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/test_cmark_spec/test_spec.py b/tests/test_cmark_spec/test_spec.py new file mode 100644 index 0000000..88d9fca --- /dev/null +++ b/tests/test_cmark_spec/test_spec.py @@ -0,0 +1,35 @@ +"""In this module tests are run against the full test set, +provided by https://github.com/commonmark/CommonMark.git. +""" +import json +from pathlib import Path + +import pytest + +from markdown_it import MarkdownIt + +SPEC_INPUT = Path(__file__).parent.joinpath("spec.md") +TESTS_INPUT = Path(__file__).parent.joinpath("commonmark.json") + + +def test_file(file_regression): + md = MarkdownIt("commonmark") + file_regression.check(md.render(SPEC_INPUT.read_text()), extension=".html") + + +@pytest.mark.parametrize("entry", json.loads(TESTS_INPUT.read_text())) +def test_spec(entry): + md = MarkdownIt("commonmark") + output = md.render(entry["markdown"]) + expected = entry["html"] + + if entry["example"] == 596: + # this doesn't have any bearing on the output + output = output.replace("mailto", "MAILTO") + if entry["example"] in [218, 239, 240]: + # this doesn't have any bearing on the output + output = output.replace( + "<blockquote></blockquote>", "<blockquote>\n</blockquote>" + ) + + assert output == expected |