mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-10 00:13:55 -04:00
test_qgsrasterfilewritertask.py: test failure
This commit is contained in:
parent
5e70084d32
commit
bbaa62af0c
@ -99,6 +99,30 @@ class TestQgsRasterFileWriterTask(unittest.TestCase):
|
||||
self.assertFalse(self.fail)
|
||||
self.assertTrue(os.path.exists(tmp))
|
||||
|
||||
def testFail(self):
|
||||
"""test error writing a layer"""
|
||||
path = os.path.join(unitTestDataPath(), 'raster', 'with_color_table.tif')
|
||||
raster_layer = QgsRasterLayer(path, "test")
|
||||
self.assertTrue(raster_layer.isValid())
|
||||
|
||||
pipe = QgsRasterPipe()
|
||||
self.assertTrue(pipe.set(raster_layer.dataProvider().clone()))
|
||||
|
||||
tmp = create_temp_filename("/this/is/invalid/file.tif")
|
||||
writer = QgsRasterFileWriter(tmp)
|
||||
|
||||
task = QgsRasterFileWriterTask(writer, pipe, 100, 100, raster_layer.extent(), raster_layer.crs(), QgsCoordinateTransformContext())
|
||||
|
||||
task.writeComplete.connect(self.onSuccess)
|
||||
task.errorOccurred.connect(self.onFail)
|
||||
|
||||
QgsApplication.taskManager().addTask(task)
|
||||
while not self.success and not self.fail:
|
||||
QCoreApplication.processEvents()
|
||||
|
||||
self.assertFalse(self.success)
|
||||
self.assertTrue(self.fail)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Loading…
x
Reference in New Issue
Block a user