@@ -291,42 +291,6 @@ def test_reader_shapefile_extension_ignored():
291291 assert not os .path .exists (filename )
292292
293293
294- def test_reader_dbf_only ():
295- """
296- Assert that specifying just the
297- dbf argument to the shapefile reader
298- reads just the dbf file.
299- """
300- with shapefile .Reader (dbf = "shapefiles/blockgroups.dbf" ) as sf :
301- assert len (sf ) == 663
302- record = sf .record (3 )
303- assert record [1 :3 ] == ['060750601001' , 4715 ]
304-
305-
306- def test_reader_shp_shx_only ():
307- """
308- Assert that specifying just the
309- shp and shx argument to the shapefile reader
310- reads just the shp and shx file.
311- """
312- with shapefile .Reader (shp = "shapefiles/blockgroups.shp" , shx = "shapefiles/blockgroups.shx" ) as sf :
313- assert len (sf ) == 663
314- shape = sf .shape (3 )
315- assert len (shape .points ) is 173
316-
317-
318- def test_reader_shx_optional ():
319- """
320- Assert that specifying just the
321- shp argument to the shapefile reader
322- reads just the shp file (shx optional).
323- """
324- with shapefile .Reader (shp = "shapefiles/blockgroups.shp" ) as sf :
325- assert len (sf ) == 663
326- shape = sf .shape (3 )
327- assert len (shape .points ) is 173
328-
329-
330294def test_reader_filelike_dbf_only ():
331295 """
332296 Assert that specifying just the
@@ -363,6 +327,20 @@ def test_reader_filelike_shx_optional():
363327 assert len (shape .points ) is 173
364328
365329
330+ def test_reader_shapefile_delayed_load ():
331+ """
332+ Assert that the filename's extension is
333+ ignored when reading a shapefile.
334+ """
335+ with shapefile .Reader () as sf :
336+ # assert that data request raises exception, since no file has been provided yet
337+ with pytest .raises (shapefile .ShapefileException ):
338+ sf .shape (0 )
339+ # assert that works after loading file manually
340+ sf .load ("shapefiles/blockgroups" )
341+ assert len (sf ) == 663
342+
343+
366344def test_records_match_shapes ():
367345 """
368346 Assert that the number of records matches
0 commit comments