1414 none ,
1515 one_of ,
1616 tuples ,
17+ sampled_from ,
1718)
1819
1920import shapefile as shp
@@ -378,4 +379,42 @@ def test_PolygonZ_roundtrips(
378379 assert actual .parts == expected .parts , f"{ type (actual .parts )= } , { type (expected .parts )= } "
379380 assert actual .m == expected .m , f"{ type (actual .m )= } , { type (expected .m )= } "
380381 assert actual .z == expected .z , f"{ type (actual .z )= } , { type (expected .z )= } "
381- assert actual .oid == expected .oid
382+ assert actual .oid == expected .oid
383+
384+ part_types = sampled_from (range (6 )) # 0: Triangle Strip, ..., 5: Ring
385+ @composite
386+ def multipatches (draw ):
387+ N = draw (PointsLengths )
388+ p_types = draw (lists (part_types , min_size = N , max_size = N ))
389+ patches = draw (lists (lists (tuples (xs , ys , zs , ms ), min_size = 1 ), min_size = N , max_size = N ))
390+ return shp .MultiPatch (lines = patches , partTypes = p_types , oid = oid )
391+
392+
393+
394+
395+ @pytest .mark .hypothesis
396+ @settings (suppress_health_check = [HealthCheck .too_slow , HealthCheck .data_too_large ])
397+ @given (expected = multipatches (), i = integers (min_value = 1 ))
398+ def test_MultiPatch_roundtrips (
399+ expected : shp .MultiPatch ,
400+ i : int ,
401+ ) -> None :
402+ stream = io .BytesIO ()
403+ n = shp .MultiPatch .write_to_byte_stream (b_io = stream , s = expected , i = i )
404+ assert n == stream .tell ()
405+ stream .seek (0 )
406+ actual = shp .MultiPatch .from_byte_stream (
407+ shapeType = shp .MULTIPATCH ,
408+ b_io = stream ,
409+ next_shape_pos = n ,
410+ oid = expected .oid ,
411+ bbox = None ,
412+ )
413+ assert isinstance (actual , shp .MultiPatch )
414+ assert actual .points_3D == expected .points_3D
415+
416+ assert actual .parts == expected .parts , f"{ type (actual .parts )= } , { type (expected .parts )= } "
417+ assert actual .m == expected .m , f"{ type (actual .m )= } , { type (expected .m )= } "
418+ assert actual .z == expected .z , f"{ type (actual .z )= } , { type (expected .z )= } "
419+ assert actual .oid == expected .oid
420+ assert actual .partTypes == expected .partTypes , f"{ type (actual .partTypes )= } , { type (expected .partTypes )= } "
0 commit comments