File: test_saneheaders.py

package info (click to toggle)
pymdown-extensions 10.13-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,104 kB
  • sloc: python: 60,117; javascript: 846; sh: 8; makefile: 5
file content (99 lines) | stat: -rw-r--r-- 2,351 bytes parent folder | download | duplicates (3)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
"""Test cases for SaneHeaders."""
from .. import util


class TestSaneHeadersWithMagicLink(util.MdCase):
    """Test cases for SaneHeaders and MagicLink (the motivation behind creating SaneHeaders)."""

    extension = [
        'pymdownx.saneheaders',
        'pymdownx.magiclink',
    ]

    extension_configs = {
        'pymdownx.magiclink': {
            'repo_url_shorthand': True,
            'user': 'facelessuser',
            'repo': 'pymdown-extensions'
        }
    }

    def test_header1(self):
        """Test header level 1."""

        self.check_markdown(
            r'# Header',
            r'<h1>Header</h1>'
        )

    def test_header2(self):
        """Test header level 2."""

        self.check_markdown(
            r'## Header',
            r'<h2>Header</h2>'
        )

    def test_header3(self):
        """Test header level 3."""

        self.check_markdown(
            r'### Header',
            r'<h3>Header</h3>'
        )

    def test_header4(self):
        """Test header level 4."""

        self.check_markdown(
            r'#### Header',
            r'<h4>Header</h4>'
        )

    def test_header5(self):
        """Test header level 5."""

        self.check_markdown(
            r'##### Header',
            r'<h5>Header</h5>'
        )

    def test_header6(self):
        """Test header level 6."""

        self.check_markdown(
            r'###### Header',
            r'<h6>Header</h6>'
        )

    def test_header_trailing(self):
        """Test header trailing hashes."""

        self.check_markdown(
            r'## Header ##',
            r'<h2>Header</h2>'
        )

    def test_too_many_hashes(self):
        """Test header with too many hashes."""

        self.check_markdown(
            r'####### Header',
            r'<p>####### Header</p>'
        )

    def test_no_header(self):
        """Test no header match."""

        self.check_markdown(
            r'##Header',
            r'<p>##Header</p>'
        )

    def test_header_with_magiclink(self):
        """Test no header match."""

        self.check_markdown(
            r'#3',
            r'<p><a class="magiclink magiclink-github magiclink-issue" href="https://github.com/facelessuser/pymdown-extensions/issues/3" title="GitHub Issue: facelessuser/pymdown-extensions #3">#3</a></p>'  # noqa: E501
        )