Skip to content

Commit 9801c41

Browse files
committed
Restore Python <=3.9 style nested with statements
1 parent 2601071 commit 9801c41

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

test_shapefile.py

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,30 +1000,28 @@ def test_shape_oid_no_shx():
10001000
basename = "shapefiles/blockgroups"
10011001
shp = open(basename + ".shp", "rb")
10021002
dbf = open(basename + ".dbf", "rb")
1003-
with (
1004-
shapefile.Reader(shp=shp, dbf=dbf) as sf,
1005-
shapefile.Reader(basename) as sf_expected,
1006-
):
1007-
for i in range(len(sf)):
1008-
shape = sf.shape(i)
1009-
assert shape.oid == i
1010-
shape_expected = sf_expected.shape(i)
1011-
assert shape.__geo_interface__ == shape_expected.__geo_interface__
1012-
1013-
for i, shape in enumerate(sf.shapes()):
1014-
assert shape.oid == i
1015-
shape_expected = sf_expected.shape(i)
1016-
assert shape.__geo_interface__ == shape_expected.__geo_interface__
1017-
1018-
for i, shape in enumerate(sf.iterShapes()):
1019-
assert shape.oid == i
1020-
shape_expected = sf_expected.shape(i)
1021-
assert shape.__geo_interface__ == shape_expected.__geo_interface__
1022-
1023-
for i, shaperec in enumerate(sf.iterShapeRecords()):
1024-
assert shaperec.shape.oid == i
1025-
shape_expected = sf_expected.shape(i)
1026-
assert shaperec.shape.__geo_interface__ == shape_expected.__geo_interface__
1003+
with shapefile.Reader(shp=shp, dbf=dbf) as sf:
1004+
with shapefile.Reader(basename) as sf_expected:
1005+
for i in range(len(sf)):
1006+
shape = sf.shape(i)
1007+
assert shape.oid == i
1008+
shape_expected = sf_expected.shape(i)
1009+
assert shape.__geo_interface__ == shape_expected.__geo_interface__
1010+
1011+
for i, shape in enumerate(sf.shapes()):
1012+
assert shape.oid == i
1013+
shape_expected = sf_expected.shape(i)
1014+
assert shape.__geo_interface__ == shape_expected.__geo_interface__
1015+
1016+
for i, shape in enumerate(sf.iterShapes()):
1017+
assert shape.oid == i
1018+
shape_expected = sf_expected.shape(i)
1019+
assert shape.__geo_interface__ == shape_expected.__geo_interface__
1020+
1021+
for i, shaperec in enumerate(sf.iterShapeRecords()):
1022+
assert shaperec.shape.oid == i
1023+
shape_expected = sf_expected.shape(i)
1024+
assert shaperec.shape.__geo_interface__ == shape_expected.__geo_interface__
10271025

10281026

10291027
def test_reader_offsets():

0 commit comments

Comments
 (0)