@@ -46,7 +46,6 @@ def test_project_roundtrip(self):
46
46
copyfile (os .path .join (TEST_DATA_DIR , 'lines.%s' % ext ), os .path .join (temp_dir .path (), 'lines.%s' % ext ))
47
47
copyfile (os .path .join (TEST_DATA_DIR , 'raster' , 'band1_byte_ct_epsg4326.tif' ), os .path .join (temp_dir .path (), 'band1_byte_ct_epsg4326.tif' ))
48
48
l = QgsVectorLayer (os .path .join (temp_dir .path (), 'lines.shp' ), 'lines' , 'ogr' )
49
- wkb_type = l .wkbType ()
50
49
self .assertTrue (l .isValid ())
51
50
52
51
rl = QgsRasterLayer (os .path .join (temp_dir .path (), 'band1_byte_ct_epsg4326.tif' ), 'raster' , 'gdal' )
@@ -66,11 +65,13 @@ def test_project_roundtrip(self):
66
65
# Load the bad project
67
66
self .assertTrue (p .read (bad_project_path ))
68
67
# Check layer is invalid
69
- invalid = list (p .mapLayersByName ('lines' ))[0 ]
70
- self .assertFalse (invalid .isValid ())
68
+ vector = list (p .mapLayersByName ('lines' ))[0 ]
69
+ raster = list (p .mapLayersByName ('raster' ))[0 ]
70
+ self .assertFalse (vector .isValid ())
71
71
# Try a getFeatures
72
- self .assertEqual ([f for f in invalid .getFeatures ()], [])
73
- self .assertTrue (list (p .mapLayers ().values ())[1 ].isValid ())
72
+ self .assertEqual ([f for f in vector .getFeatures ()], [])
73
+ self .assertTrue (raster .isValid ())
74
+ self .assertEqual (vector .providerType (), 'ogr' )
74
75
75
76
# Save the project
76
77
bad_project_path2 = os .path .join (temp_dir .path (), 'project_bad2.qgs' )
@@ -84,8 +85,10 @@ def test_project_roundtrip(self):
84
85
# Load the good project
85
86
self .assertTrue (p .read (good_project_path ))
86
87
# Check layer is valid
87
- self .assertTrue (list (p .mapLayers ().values ())[0 ].isValid ())
88
- self .assertTrue (list (p .mapLayers ().values ())[1 ].isValid ())
88
+ vector = list (p .mapLayersByName ('lines' ))[0 ]
89
+ raster = list (p .mapLayersByName ('raster' ))[0 ]
90
+ self .assertTrue (vector .isValid ())
91
+ self .assertTrue (raster .isValid ())
89
92
90
93
91
94
if __name__ == '__main__' :
0 commit comments