コード例 #1
0
ファイル: test_ecma48.py プロジェクト: skripkar/noc
def test_backspace():
    # Single backspace
    assert strip_control_sequences("123\x084") == "124"
    # Triple backspace
    assert strip_control_sequences("123\x08\x08\x084") == "4"
    # Backspaces followed with spaces
    assert strip_control_sequences(
        "\x08 \x08\x08 \x08\x08 \x08\x08 test") == " test"
コード例 #2
0
ファイル: test_ecma48.py プロジェクト: skripkar/noc
def test_CSI():
    # CSI without P and I stripped
    assert strip_control_sequences("\x1b[@\x1b[a\x1b[~") == ""
    # CSI with I stripped
    assert strip_control_sequences("\x1b[ @\x1b[/~") == ""
    # CSI with P and I stripped
    assert strip_control_sequences("\x1b[0 @\x1b[0;7/~") == ""
    # Cleaned stream
    assert strip_control_sequences(
        "L\x1b[@or\x1b[/~em\x1b[0 @ Ips\x1b[0;7/~um\x07") == "Lorem Ipsum"
コード例 #3
0
 def cleaned_input(self, input):
     """
     Preprocessor to clean up and normalize input from device.
     Delete ASCII sequences by default.
     Can be overriden to achieve desired behavior
     """
     return strip_control_sequences(input)
コード例 #4
0
ファイル: test_ecma48.py プロジェクト: skripkar/noc
def test_C1_stripped():
    """
    C1 set stripped (ESC+[ survive)
    :return:
    """
    assert strip_control_sequences("".join(
        ["\x1b" + chr(i) for i in range(64, 96)])) == "\x1b["
コード例 #5
0
ファイル: test_ecma48.py プロジェクト: skripkar/noc
def test_control_survive():
    """
    CR,LF and ESC survive from C0 set
    :return:
    """
    assert strip_control_sequences("".join([chr(i)
                                            for i in range(32)])) == "\t\n\r"
コード例 #6
0
def test_backspace(config, expected):
    """
    Single backspace
    Triple backspace
    Backspaces followed with spaces
    :return:
    """
    assert strip_control_sequences(config) == expected
コード例 #7
0
def test_CSI(config, expected):
    """
    CSI without P and I stripped
    CSI with I stripped
    CSI with P and I stripped
    Cleaned stream
    :return:
    """
    assert strip_control_sequences(config) == expected
コード例 #8
0
ファイル: test_ecma48.py プロジェクト: skripkar/noc
def test_ascii_mess():
    """
    ASCII mess
    :return:
    """
    assert strip_control_sequences(
        "\x1b[2J\x1b[?7l\x1b[3;23r\x1b[?6l\x1b[24;27H\x1b[?25h\x1b[24;27H"
        "\x1b[?6l\x1b[1;24r\x1b[?7l\x1b[2J\x1b[24;27H\x1b[1;24r\x1b[24;27H"
        "\x1b[2J\x1b[?7l\x1b[1;24r\x1b[?6l\x1b[24;1H\x1b[1;24r\x1b[24;1H"
        "\x1b[24;1H\x1b[2K\x1b[24;1H\x1b[?25h\x1b[24;1H\x1b[24;1Hswitch# "
        "\x1b[24;1H\x1b[24;13H\x1b[24;1H\x1b[?25h\x1b[24;13H") == "switch# "
コード例 #9
0
def test_incomplete_CSI(config, expected):
    """
    Incomplete CSI passed
    :return:
    """
    assert strip_control_sequences(config) == expected
コード例 #10
0
def test_C1_stripped(config, expected):
    """
    C1 set stripped (ESC+[ survive)
    :return:
    """
    assert strip_control_sequences(config) == expected
コード例 #11
0
def test_control_survive(config, expected):
    """
    CR,LF and ESC survive from C0 set
    :return:
    """
    assert strip_control_sequences(config) == expected
コード例 #12
0
def test_strip_normal(config, expected):
    """
    Normal text leaved untouched
    :return:
    """
    assert strip_control_sequences(config) == expected
コード例 #13
0
def test_ascii_mess(config, expected):
    """
    ASCII mess
    :return:
    """
    assert strip_control_sequences(config) == expected
コード例 #14
0
ファイル: test_ecma48.py プロジェクト: skripkar/noc
def test_incomplete_CSI():
    """
    Incomplete CSI passed
    :return:
    """
    assert strip_control_sequences("\x1b[") == "\x1b["
コード例 #15
0
ファイル: test_ecma48.py プロジェクト: skripkar/noc
def test_incomplete_C1():
    """
    Incomplete C1 passed
    """
    assert strip_control_sequences("\x1b") == "\x1b"
コード例 #16
0
ファイル: test_ecma48.py プロジェクト: skripkar/noc
def test_strip_normal():
    """
    Normal text leaved untouched
    :return:
    """
    assert strip_control_sequences("Lorem Ipsum") == "Lorem Ipsum"