Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cc82ec8

Browse filesBrowse files
committed
Add test for iterRecords new start and stop args; ensure same Records returned as from Reader.record
1 parent 74cf6dd commit cc82ec8
Copy full SHA for cc82ec8

File tree

Expand file treeCollapse file tree

1 file changed

+24
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+24
-0
lines changed

‎test_shapefile.py

Copy file name to clipboardExpand all lines: test_shapefile.py
+24Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44

55
import datetime
6+
import itertools
67
import json
78
import os.path
89

@@ -968,10 +969,33 @@ def test_record_oid():
968969
for i, record in enumerate(sf.iterRecords()):
969970
assert record.oid == i
970971

972+
971973
for i, shaperec in enumerate(sf.iterShapeRecords()):
972974
assert shaperec.record.oid == i
973975

974976

977+
def test_iterRecords_start_stop():
978+
"""
979+
Assert that Reader.iterRecords(start, stop)
980+
returns the correct records, as if searched for
981+
by Reader..
982+
"""
983+
984+
985+
with shapefile.Reader("shapefiles/blockgroups") as sf:
986+
987+
N = len(sf)
988+
989+
# Arbitrary selection of start values
990+
for start in [0, 1, 2, 3, 5, 11, 17, 33, 51, 103, 170, 234, 435, 543, N-3, N-2, N-1]:
991+
for stop in range(start, len(sf)):
992+
# test negative indexing from end, as well as
993+
# positive values of stop, and its default
994+
for stop_arg in (stop, stop - len(sf), None):
995+
for record in sf.iterRecords(start = start, stop = stop):
996+
assert record == sf.record(record.oid)
997+
998+
975999
def test_shape_oid():
9761000
"""
9771001
Assert that the shape's oid attribute returns

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.