2727zs = one_of (just (0.0 ), float_nums )
2828PointsLengths = integers (min_value = 1 , max_value = 8000 ) # length of points
2929oid = one_of (none (), integers (min_value = 0 ))
30+ null_shapes = builds (shp .NullShape , oid = oid )
3031point_2D = builds (shp .Point , x = xs , y = ys , oid = oid )
3132pointm = builds (
3233 shp .PointM ,
@@ -419,7 +420,7 @@ def test_MultiPatch_roundtrips(
419420 # a Null shape).
420421
421422shape_codes_names_and_strategies = [
422- # (0, "Null Shape"),
423+ (0 , "Null Shape" , null_shapes ),
423424(1 , "Point" , point_2D ),
424425(3 , "PolyLine" , polyline ),
425426(5 , "Polygon" , polygon ),
@@ -437,8 +438,14 @@ def test_MultiPatch_roundtrips(
437438
438439def code_and_shape_strat_from_triple (t ):
439440 x , _name , shapes = t
440- return tuples (just (x ), lists (shapes , min_size = 0 , max_size = MAX_NUM_SHAPES )) # Empty shp files are in the esri spec.
441-
441+ return tuples (
442+ just (x ),
443+ lists (
444+ one_of (shapes , null_shapes ),
445+ min_size = 0 , # Empty shp files are in the ESRI spec.
446+ max_size = MAX_NUM_SHAPES ,
447+ ),
448+ )
442449codes_and_shapes_strats = [
443450 code_and_shape_strat_from_triple (t )
444451 for t in shape_codes_names_and_strategies
@@ -460,7 +467,7 @@ def test_shp_reader_writer_roundtrip(codes_and_shapes)-> None:
460467
461468 for actual , expected in itertools .zip_longest (r .shapes (), expected_shapes ):
462469
463- assert isinstance (actual , shp .SHAPE_CLASS_FROM_SHAPETYPE [code_ex ])
470+ assert isinstance (actual , ( shp .SHAPE_CLASS_FROM_SHAPETYPE [code_ex ], shp . NullShape ) )
464471 assert actual .points_3D == expected .points_3D
465472 # Don't assert actual.oid == expected.oid it's defined by
466473 # actual.oid indicates the order actual was written in, expected.oid
@@ -484,35 +491,6 @@ def test_shp_reader_writer_roundtrip(codes_and_shapes)-> None:
484491
485492
486493
487- # SHX_UB = MAX_FILE_SIZE_16bw - 50
488-
489-
490- # ## Surprisingly slow. Doesn't add enough value to merit waiting for
491- # @composite
492- # def positive_ints_with_bounded_sum(
493- # draw,
494- # min_x: int = 6,
495- # upper_bound: int = SHX_UB,
496- # max_len: int = MAX_NUM_SHAPES,
497- # ):
498- # assert min_x >= 1
499- # assert upper_bound >= max_len
500- # length = draw(integers(min_value=0, max_value=max_len))
501- # if length == 0:
502- # return []
503-
504- # max_x = upper_bound - (length - 1)
505- # result = []
506-
507- # for i in range(length):
508- # if max_x < min_x :
509- # break
510- # x = draw(integers(min_value=min_x, max_value=max_x))
511- # result.append(x)
512- # max_x -= x
513-
514- # return result
515-
516494
517495@pytest .mark .hypothesis
518496@given (codes_and_shapes = codes_and_shapes )
0 commit comments