File: test_renderer_util.py

package info (click to toggle)
mdformat 1.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 748 kB
  • sloc: python: 11,287; makefile: 9
file content (26 lines) | stat: -rw-r--r-- 678 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
import pytest

from mdformat.renderer import _util


@pytest.mark.parametrize(
    "in_, indexes, out",
    [
        ("text", [0], ["", "text"]),
        ("text", [3], ["tex", "t"]),
        ("text", [4], ["text", ""]),
        (
            "lorem dipsum iksum lopsum",
            [0, 1, 6, 7],
            ["", "l", "orem ", "d", "ipsum iksum lopsum"],
        ),
    ],
)
def test_split_at_indexes(in_, indexes, out):
    assert _util.split_at_indexes(in_, indexes) == out


def test_split_at_indexes__valueerror():
    with pytest.raises(ValueError) as exc_info:
        _util.split_at_indexes("testtext", ())
    assert "indexes must not be empty" in str(exc_info.value)