File: test_sanitize_text.py

package info (click to toggle)
python-briefcase 0.3.22-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,300 kB
  • sloc: python: 59,405; makefile: 57
file content (33 lines) | stat: -rw-r--r-- 866 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
30
31
32
33
import pytest

from briefcase.console import sanitize_text


@pytest.mark.parametrize(
    "input_text, sanitized_text",
    [
        (
            "log output",
            "log output",
        ),
        (
            "ls\n\x1b[00m\x1b[01;31mexamplefile.zip\x1b[00m\n\x1b[01;31m",
            "ls\nexamplefile.zip\n",
        ),
        (
            "log output: \u001b[31mRed\u001b[0m",
            "log output: Red",
        ),
        (
            "\u001b[1mbold log output:\u001b[0m \u001b[4mUnderline\u001b[0m",
            "bold log output: Underline",
        ),
        (
            f"{chr(7)}{chr(8)}{chr(11)}{chr(12)}{chr(13)}log{chr(7)} output{chr(7)}",
            "log output",
        ),
    ],
)
def test_sanitize_text(input_text, sanitized_text):
    """Text is sanitized as expected."""
    assert sanitize_text(input_text) == sanitized_text