Exemplo n.º 1
0
def test_stripControlChars():
    """Ensure we properly remove control characters (not including \r\n\t"""
    controlCharText = ''.join(StringUtils.INVALID_CONTROL_CHARACTERS) + \
                      "THE STRING" + ''.join(StringUtils.INVALID_CONTROL_CHARACTERS)
    assert StringUtils.stripControlChars(controlCharText) == "THE STRING"
    assert StringUtils.stripControlChars(controlCharText, fromFront=False) == \
              ''.join(StringUtils.INVALID_CONTROL_CHARACTERS) + "THE STRING"
    assert StringUtils.stripControlChars(controlCharText, fromBack=False) == \
              "THE STRING" + ''.join(StringUtils.INVALID_CONTROL_CHARACTERS)
    assert StringUtils.stripControlChars(controlCharText, fromFront=False, fromBack=False) == \
              ''.join(StringUtils.INVALID_CONTROL_CHARACTERS) + "THE STRING" + \
              ''.join(StringUtils.INVALID_CONTROL_CHARACTERS)
Exemplo n.º 2
0
def test_stripControlChars():
    """Ensure we properly remove control characters (not including \r\n\t"""
    controlCharText = ''.join(StringUtils.INVALID_CONTROL_CHARACTERS) + \
                      "THE STRING" + ''.join(StringUtils.INVALID_CONTROL_CHARACTERS)
    assert StringUtils.stripControlChars(controlCharText) == "THE STRING"
    assert StringUtils.stripControlChars(controlCharText, fromFront=False) == \
              ''.join(StringUtils.INVALID_CONTROL_CHARACTERS) + "THE STRING"
    assert StringUtils.stripControlChars(controlCharText, fromBack=False) == \
              "THE STRING" + ''.join(StringUtils.INVALID_CONTROL_CHARACTERS)
    assert StringUtils.stripControlChars(controlCharText, fromFront=False, fromBack=False) == \
              ''.join(StringUtils.INVALID_CONTROL_CHARACTERS) + "THE STRING" + \
              ''.join(StringUtils.INVALID_CONTROL_CHARACTERS)