MCPcopy
hub / github.com/django/django / test01_valid_shp

Method test01_valid_shp

tests/gis_tests/gdal_tests/test_ds.py:115–139  ·  view source on GitHub ↗

Testing valid SHP Data Source files.

(self)

Source from the content-addressed store, hash-verified

113
114class DataSourceTest(SimpleTestCase):
115 def test01_valid_shp(self):
116 "Testing valid SHP Data Source files."
117
118 for source in ds_list:
119 # Loading up the data source
120 ds = DataSource(source.ds)
121
122 # The layer count is what's expected (only 1 layer in a SHP file).
123 self.assertEqual(1, len(ds))
124
125 # Making sure GetName works
126 self.assertEqual(source.ds, ds.name)
127
128 # Making sure the driver name matches up
129 self.assertEqual(source.driver, str(ds.driver))
130
131 # Making sure indexing works
132 msg = "Index out of range when accessing layers in a datasource: %s."
133 with self.assertRaisesMessage(IndexError, msg % len(ds)):
134 ds.__getitem__(len(ds))
135
136 with self.assertRaisesMessage(
137 IndexError, "Invalid OGR layer name given: invalid."
138 ):
139 ds.__getitem__("invalid")
140
141 def test_ds_input_pathlib(self):
142 test_shp = Path(get_ds_file("test_point", "shp"))

Callers

nothing calls this directly

Calls 3

__getitem__Method · 0.95
DataSourceClass · 0.90
assertRaisesMessageMethod · 0.80

Tested by

no test coverage detected