• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

earwig / mwparserfromhell / 15949141982

28 Jun 2025 11:18PM UTC coverage: 98.886% (-0.3%) from 99.204%
15949141982

push

github

earwig
Fix a failing test

3106 of 3141 relevant lines covered (98.89%)

9.85 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.3
/src/mwparserfromhell/nodes/heading.py
1
# Copyright (C) 2012-2025 Ben Kurtovic <ben.kurtovic@gmail.com>
2
#
3
# Permission is hereby granted, free of charge, to any person obtaining a copy
4
# of this software and associated documentation files (the "Software"), to deal
5
# in the Software without restriction, including without limitation the rights
6
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
# copies of the Software, and to permit persons to whom the Software is
8
# furnished to do so, subject to the following conditions:
9
#
10
# The above copyright notice and this permission notice shall be included in
11
# all copies or substantial portions of the Software.
12
#
13
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
# SOFTWARE.
20

21
from __future__ import annotations
10✔
22

23
from collections.abc import Generator
10✔
24
from typing import TYPE_CHECKING, Any, Callable
10✔
25

26
from ..utils import parse_anything
10✔
27
from ._base import Node
10✔
28

29
if TYPE_CHECKING:
10✔
30
    from ..wikicode import Wikicode
×
31

32

33
class Heading(Node):
10✔
34
    """Represents a section heading in wikicode, like ``== Foo ==``."""
35

36
    def __init__(self, title: Any, level: int):
10✔
37
        super().__init__()
10✔
38
        self.title = title
10✔
39
        self.level = level
10✔
40

41
    def __str__(self) -> str:
10✔
42
        return ("=" * self.level) + str(self.title) + ("=" * self.level)
10✔
43

44
    def __children__(self) -> Generator[Wikicode, None, None]:
10✔
45
        yield self.title
10✔
46

47
    def __strip__(self, **kwargs: Any) -> str | None:
10✔
48
        return self.title.strip_code(**kwargs)
10✔
49

50
    def __showtree__(
10✔
51
        self,
52
        write: Callable[[str], None],
53
        get: Callable[[Wikicode], None],
54
        mark: Callable[[], None],
55
    ) -> None:
56
        write("=" * self.level)
10✔
57
        get(self.title)
10✔
58
        write("=" * self.level)
10✔
59

60
    @property
10✔
61
    def title(self) -> Wikicode:
10✔
62
        """The title of the heading, as a :class:`.Wikicode` object."""
63
        return self._title
10✔
64

65
    @title.setter
10✔
66
    def title(self, value: Any) -> None:
10✔
67
        self._title = parse_anything(value)
10✔
68

69
    @property
10✔
70
    def level(self) -> int:
10✔
71
        """The heading level, as an integer between 1 and 6, inclusive."""
72
        return self._level
10✔
73

74
    @level.setter
10✔
75
    def level(self, value: int) -> None:
10✔
76
        value = int(value)
10✔
77
        if value < 1 or value > 6:
10✔
78
            raise ValueError(value)
10✔
79
        self._level = value
10✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc