File: test_extension.py

package info (click to toggle)
markdown-callouts 0.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 420 kB
  • sloc: python: 195; sh: 17; makefile: 15
file content (29 lines) | stat: -rw-r--r-- 954 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import re

import bs4
import pytest
from markdown import Markdown

from markdown_callouts.callouts import CalloutsExtension
from markdown_callouts.github_callouts import GitHubCalloutsExtension

extension_styles = {
    "callouts": CalloutsExtension,
    "github": GitHubCalloutsExtension,
}


@pytest.mark.golden_test("callouts/**/*.yml", "github/**/*.yml", "all/**/*.yml")
def test_extension(request, golden):
    config = {k: golden[k] for k in ["strip_period"] if golden.get(k) is not None}
    extensions = [
        extension(**config)
        for key, extension in extension_styles.items()
        if f"{key}/" in request.node.name or "all/" in request.node.name
    ]
    md = Markdown(extensions=extensions)
    output = md.convert(golden["input"])
    soup = bs4.BeautifulSoup(output, features="html.parser")
    html = soup.prettify().rstrip("\n")
    html = re.sub(r"^( *)", r"\1\1", html, flags=re.M)
    assert html == golden.out["output"]