@@ -416,6 +416,56 @@ def test_reader_pathlike():
416
416
assert len (sf ) == 663
417
417
418
418
419
+ def test_reader_dbf_only ():
420
+ """
421
+ Assert that specifying just the
422
+ dbf argument to the shapefile reader
423
+ reads just the dbf file.
424
+ """
425
+ with shapefile .Reader (dbf = "shapefiles/blockgroups.dbf" ) as sf :
426
+ assert len (sf ) == 663
427
+ record = sf .record (3 )
428
+ assert record [1 :3 ] == ['060750601001' , 4715 ]
429
+
430
+
431
+ def test_reader_shp_shx_only ():
432
+ """
433
+ Assert that specifying just the
434
+ shp and shx argument to the shapefile reader
435
+ reads just the shp and shx file.
436
+ """
437
+ with shapefile .Reader (shp = "shapefiles/blockgroups.shp" , shx = "shapefiles/blockgroups.shx" ) as sf :
438
+ assert len (sf ) == 663
439
+ shape = sf .shape (3 )
440
+ assert len (shape .points ) is 173
441
+
442
+
443
+ def test_reader_shp_dbf_only ():
444
+ """
445
+ Assert that specifying just the
446
+ shp and shx argument to the shapefile reader
447
+ reads just the shp and dbf file.
448
+ """
449
+ with shapefile .Reader (shp = "shapefiles/blockgroups.shp" , dbf = "shapefiles/blockgroups.dbf" ) as sf :
450
+ assert len (sf ) == 663
451
+ shape = sf .shape (3 )
452
+ assert len (shape .points ) is 173
453
+ record = sf .record (3 )
454
+ assert record [1 :3 ] == ['060750601001' , 4715 ]
455
+
456
+
457
+ def test_reader_shp_only ():
458
+ """
459
+ Assert that specifying just the
460
+ shp argument to the shapefile reader
461
+ reads just the shp file (shx optional).
462
+ """
463
+ with shapefile .Reader (shp = "shapefiles/blockgroups.shp" ) as sf :
464
+ assert len (sf ) == 663
465
+ shape = sf .shape (3 )
466
+ assert len (shape .points ) is 173
467
+
468
+
419
469
def test_reader_filelike_dbf_only ():
420
470
"""
421
471
Assert that specifying just the
@@ -440,7 +490,21 @@ def test_reader_filelike_shp_shx_only():
440
490
assert len (shape .points ) is 173
441
491
442
492
443
- def test_reader_filelike_shx_optional ():
493
+ def test_reader_filelike_shp_dbf_only ():
494
+ """
495
+ Assert that specifying just the
496
+ shp and shx argument to the shapefile reader
497
+ reads just the shp and dbf file.
498
+ """
499
+ with shapefile .Reader (shp = open ("shapefiles/blockgroups.shp" , "rb" ), dbf = open ("shapefiles/blockgroups.dbf" , "rb" )) as sf :
500
+ assert len (sf ) == 663
501
+ shape = sf .shape (3 )
502
+ assert len (shape .points ) is 173
503
+ record = sf .record (3 )
504
+ assert record [1 :3 ] == ['060750601001' , 4715 ]
505
+
506
+
507
+ def test_reader_filelike_shp_only ():
444
508
"""
445
509
Assert that specifying just the
446
510
shp argument to the shapefile reader
0 commit comments