@@ -721,8 +721,7 @@ def test_reader_pathlike():
721721 """
722722 Assert that path-like objects can be read.
723723 """
724- base = Path ("shapefiles" )
725- with shapefile .Reader (base / "blockgroups" ) as sf :
724+ with shapefile .Reader (shapefiles_dir / "blockgroups" ) as sf :
726725 assert len (sf ) == 663
727726
728727
@@ -738,6 +737,18 @@ def test_reader_dbf_only():
738737 assert record [1 :3 ] == ["060750601001" , 4715 ]
739738
740739
740+ def test_reader_dbf_only_from_Path ():
741+ """
742+ Assert that specifying just the
743+ dbf argument to the shapefile reader as a Path
744+ reads just the dbf file.
745+ """
746+ with shapefile .Reader (dbf = shapefiles_dir / "blockgroups.dbf" ) as sf :
747+ assert len (sf ) == 663
748+ record = sf .record (3 )
749+ assert record [1 :3 ] == ["060750601001" , 4715 ]
750+
751+
741752def test_reader_shp_shx_only ():
742753 """
743754 Assert that specifying just the
@@ -752,6 +763,20 @@ def test_reader_shp_shx_only():
752763 assert len (shape .points ) == 173
753764
754765
766+ def test_reader_shp_shx_only_from_Paths ():
767+ """
768+ Assert that specifying just the
769+ shp and shx argument to the shapefile reader as Paths
770+ reads just the shp and shx file.
771+ """
772+ with shapefile .Reader (
773+ shp = shapefiles_dir / "blockgroups.shp" , shx = shapefiles_dir / "blockgroups.shx"
774+ ) as sf :
775+ assert len (sf ) == 663
776+ shape = sf .shape (3 )
777+ assert len (shape .points ) == 173
778+
779+
755780def test_reader_shp_dbf_only ():
756781 """
757782 Assert that specifying just the
@@ -768,6 +793,21 @@ def test_reader_shp_dbf_only():
768793 assert record [1 :3 ] == ["060750601001" , 4715 ]
769794
770795
796+ def test_reader_shp_dbf_only_from_Paths ():
797+ """
798+ Assert that specifying just the
799+ shp and shx argument to the shapefile reader as Paths
800+ reads just the shp and dbf file.
801+ """
802+ with shapefile .Reader (
803+ shp = shapefiles_dir / "blockgroups.shp" , dbf = shapefiles_dir / "blockgroups.dbf"
804+ ) as sf :
805+ assert len (sf ) == 663
806+ shape = sf .shape (3 )
807+ assert len (shape .points ) == 173
808+ record = sf .record (3 )
809+ assert record [1 :3 ] == ["060750601001" , 4715 ]
810+
771811def test_reader_shp_only ():
772812 """
773813 Assert that specifying just the
@@ -780,6 +820,18 @@ def test_reader_shp_only():
780820 assert len (shape .points ) == 173
781821
782822
823+ def test_reader_shp_only_from_Path ():
824+ """
825+ Assert that specifying just the
826+ shp argument to the shapefile reader as a Path
827+ reads just the shp file (shx optional).
828+ """
829+ with shapefile .Reader (shp = shapefiles_dir / "blockgroups.shp" ) as sf :
830+ assert len (sf ) == 663
831+ shape = sf .shape (3 )
832+ assert len (shape .points ) == 173
833+
834+
783835def test_reader_filelike_dbf_only ():
784836 """
785837 Assert that specifying just the
@@ -1079,6 +1131,7 @@ def test_shape_oid_no_shx():
10791131 )
10801132
10811133
1134+
10821135def test_reader_offsets ():
10831136 """
10841137 Assert that reader will not read the shx offsets unless necessary,
0 commit comments