Skip to content

Commit

Permalink
Restore Python <=3.9 style nested with statements
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesParrott committed Sep 19, 2024
1 parent 2601071 commit 9801c41
Showing 1 changed file with 22 additions and 24 deletions.
46 changes: 22 additions & 24 deletions test_shapefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1000,30 +1000,28 @@ def test_shape_oid_no_shx():
basename = "shapefiles/blockgroups"
shp = open(basename + ".shp", "rb")
dbf = open(basename + ".dbf", "rb")
with (
shapefile.Reader(shp=shp, dbf=dbf) as sf,
shapefile.Reader(basename) as sf_expected,
):
for i in range(len(sf)):
shape = sf.shape(i)
assert shape.oid == i
shape_expected = sf_expected.shape(i)
assert shape.__geo_interface__ == shape_expected.__geo_interface__

for i, shape in enumerate(sf.shapes()):
assert shape.oid == i
shape_expected = sf_expected.shape(i)
assert shape.__geo_interface__ == shape_expected.__geo_interface__

for i, shape in enumerate(sf.iterShapes()):
assert shape.oid == i
shape_expected = sf_expected.shape(i)
assert shape.__geo_interface__ == shape_expected.__geo_interface__

for i, shaperec in enumerate(sf.iterShapeRecords()):
assert shaperec.shape.oid == i
shape_expected = sf_expected.shape(i)
assert shaperec.shape.__geo_interface__ == shape_expected.__geo_interface__
with shapefile.Reader(shp=shp, dbf=dbf) as sf:
with shapefile.Reader(basename) as sf_expected:
for i in range(len(sf)):
shape = sf.shape(i)
assert shape.oid == i
shape_expected = sf_expected.shape(i)
assert shape.__geo_interface__ == shape_expected.__geo_interface__

for i, shape in enumerate(sf.shapes()):
assert shape.oid == i
shape_expected = sf_expected.shape(i)
assert shape.__geo_interface__ == shape_expected.__geo_interface__

for i, shape in enumerate(sf.iterShapes()):
assert shape.oid == i
shape_expected = sf_expected.shape(i)
assert shape.__geo_interface__ == shape_expected.__geo_interface__

for i, shaperec in enumerate(sf.iterShapeRecords()):
assert shaperec.shape.oid == i
shape_expected = sf_expected.shape(i)
assert shaperec.shape.__geo_interface__ == shape_expected.__geo_interface__


def test_reader_offsets():
Expand Down

0 comments on commit 9801c41

Please sign in to comment.