@@ -979,6 +979,23 @@ def test_array_utf8_type_error() -> None:
979979 _serialize_array (_BitWriter (), schema , 123 )
980980
981981
982+ def test_api_accepts_str_and_bytes_for_utf8_and_byte_arrays () -> None :
983+ schema = _mk_structure (
984+ "test.StringLikeArrays" ,
985+ [
986+ Field (VariableLengthArrayType (UTF8Type (), 64 ), "text" ),
987+ Field (VariableLengthArrayType (ByteType (), 64 ), "blob" ),
988+ ],
989+ )
990+
991+ cases = [
992+ ({"text" : "hello" , "blob" : b"\x00 \x01 \x02 " }, {"text" : "hello" , "blob" : b"\x00 \x01 \x02 " }),
993+ ({"text" : b"world" , "blob" : "abc" }, {"text" : "world" , "blob" : b"abc" }),
994+ ]
995+ for obj , expected in cases :
996+ assert deserialize (schema , serialize (schema , obj )) == expected
997+
998+
982999def test_array_unknown_type_error () -> None :
9831000 class MockArray :
9841001 element_type = UnsignedIntegerType (8 , CM .TRUNCATED )
@@ -1286,6 +1303,7 @@ def _unittest_serdes_branch_coverage_tests() -> None:
12861303 test_array_byte_from_list_input ((104 , 105 ))
12871304 test_array_byte_type_error ()
12881305 test_array_utf8_type_error ()
1306+ test_api_accepts_str_and_bytes_for_utf8_and_byte_arrays ()
12891307 test_array_unknown_type_error ()
12901308 test_array_deserialized_length_overflow ()
12911309 test_array_composite_elements ()
0 commit comments