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)"
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
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
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
def test_parse_field_value_string_one(): EXPECTED = "42" RESULT = parser.parse_field_value(header.FieldInfo("String", 1), "42") assert EXPECTED == RESULT
def test_parse_field_value_integer_more_empty(number): EXPECTED = [] RESULT = parser.parse_field_value(header.FieldInfo("Integer", number), ".") assert EXPECTED == RESULT
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
def test_parse_field_value_integer_one(): EXPECTED = 42 RESULT = parser.parse_field_value(header.FieldInfo("Integer", 1), "42") assert EXPECTED == RESULT
def test_parse_field_value_string_more_empty(number): EXPECTED = [] RESULT = parser.parse_field_value(header.FieldInfo("String", number), ".") assert EXPECTED == RESULT