Пример #1
0
def test_header_field_info():
    """Test the builtin functions of the FieldInfo class"""
    info1 = header.FieldInfo("Integer", 1, "Some description")
    info2 = header.FieldInfo("Integer", 1, "Some description")
    info3 = header.FieldInfo("Integer", ".", "Some description")
    assert info1 == info2
    assert info1 != info3
    assert hash(info1) == hash(info2)
    assert str(info1) == "FieldInfo('Integer', 1, 'Some description', None)"
    assert repr(info1) == "FieldInfo('Integer', 1, 'Some description', None)"
Пример #2
0
def test_format_value_without_escape():
    EXPECTED = "This is a legal string,me too"
    RESULT = writer.format_value(header.FieldInfo("String", 2),
                                 ("This is a legal string", "me too"), "INFO")
    assert EXPECTED == RESULT
Пример #3
0
def test_format_value_with_escape():
    EXPECTED = "%3A%3B%3D%25%2C%0D%0A%09,%25"
    RESULT = writer.format_value(header.FieldInfo("String", 2),
                                 (":;=%,\r\n\t", "%"), "INFO")
    assert EXPECTED == RESULT
Пример #4
0
def test_parse_field_value_string_more(number):
    EXPECTED = ["42", "43"]
    RESULT = parser.parse_field_value(header.FieldInfo("String", number),
                                      "42,43")
    assert EXPECTED == RESULT
Пример #5
0
def test_parse_field_value_string_one():
    EXPECTED = "42"
    RESULT = parser.parse_field_value(header.FieldInfo("String", 1), "42")
    assert EXPECTED == RESULT
Пример #6
0
def test_parse_field_value_integer_more_empty(number):
    EXPECTED = []
    RESULT = parser.parse_field_value(header.FieldInfo("Integer", number), ".")
    assert EXPECTED == RESULT
Пример #7
0
def test_parse_field_value_integer_more(number):
    EXPECTED = [42, 43]
    RESULT = parser.parse_field_value(header.FieldInfo("Integer", number),
                                      "42,43")
    assert EXPECTED == RESULT
Пример #8
0
def test_parse_field_value_integer_one():
    EXPECTED = 42
    RESULT = parser.parse_field_value(header.FieldInfo("Integer", 1), "42")
    assert EXPECTED == RESULT
Пример #9
0
def test_parse_field_value_string_more_empty(number):
    EXPECTED = []
    RESULT = parser.parse_field_value(header.FieldInfo("String", number), ".")
    assert EXPECTED == RESULT