File: test_strutil.py

package info (click to toggle)
pytest-mypy-testing 0.1.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 268 kB
  • sloc: python: 1,151; sh: 13; makefile: 2
file content (33 lines) | stat: -rw-r--r-- 643 bytes parent folder | download
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
# SPDX-FileCopyrightText: David Fritzsche
# SPDX-License-Identifier: CC0-1.0

import pytest

from pytest_mypy_testing.strutil import common_prefix, dedent


@pytest.mark.parametrize(
    "a,b,expected",
    [
        ("", "", ""),
        ("a", "a", "a"),
        ("abc", "abcd", "abc"),
        ("abcd", "abc", "abc"),
        ("abc", "xyz", ""),
    ],
)
def test_common_prefix(a: str, b: str, expected: str):
    actual = common_prefix(a, b)
    assert actual == expected


def test_dedent():
    input = """
    foo
    bar
        baz
    """

    expected = "foo\nbar\n    baz\n"
    actual = dedent(input)
    assert actual == expected