Skip to content
Permalink
Browse files

fix python task manager test

  • Loading branch information
troopa81 authored and nyalldawson committed Feb 19, 2020
1 parent 4aed962 commit c2a4ad4236beca0126c841c9569cf124625e0dc8
Showing with 12 additions and 12 deletions.
  1. +12 −12 tests/src/python/test_qgstaskmanager.py
@@ -79,7 +79,7 @@ def testTaskFromFunction(self):
task = QgsTask.fromFunction('test task', run, 20)
QgsApplication.taskManager().addTask(task)
while task.status() not in [QgsTask.Complete, QgsTask.Terminated]:
pass
QCoreApplication.processEvents()

self.assertEqual(task.returned_values, 20)
self.assertFalse(task.exception)
@@ -89,7 +89,7 @@ def testTaskFromFunction(self):
bad_task = QgsTask.fromFunction('test task2', run, None)
QgsApplication.taskManager().addTask(bad_task)
while bad_task.status() not in [QgsTask.Complete, QgsTask.Terminated]:
pass
QCoreApplication.processEvents()

self.assertFalse(bad_task.returned_values)
self.assertTrue(bad_task.exception)
@@ -109,7 +109,7 @@ def testTaskFromFunctionWithKwargs(self):
task = QgsTask.fromFunction('test task3', run_with_kwargs, result=5, password=1)
QgsApplication.taskManager().addTask(task)
while task.status() not in [QgsTask.Complete, QgsTask.Terminated]:
pass
QCoreApplication.processEvents()

self.assertEqual(task.returned_values, 5)
self.assertFalse(task.exception)
@@ -120,11 +120,11 @@ def testTaskFromFunctionIsCancelable(self):
bad_task = QgsTask.fromFunction('test task4', cancelable)
QgsApplication.taskManager().addTask(bad_task)
while bad_task.status() != QgsTask.Running:
pass
QCoreApplication.processEvents()

bad_task.cancel()
while bad_task.status() == QgsTask.Running:
pass
QCoreApplication.processEvents()
while QgsApplication.taskManager().countActiveTasks() > 0:
QCoreApplication.processEvents()

@@ -136,7 +136,7 @@ def testTaskFromFunctionCanSetProgress(self):
task = QgsTask.fromFunction('test task5', progress_function)
QgsApplication.taskManager().addTask(task)
while task.status() != QgsTask.Running:
pass
QCoreApplication.processEvents()

# wait a fraction so that setProgress gets a chance to be called
sleep(0.001)
@@ -145,7 +145,7 @@ def testTaskFromFunctionCanSetProgress(self):

task.cancel()
while task.status() == QgsTask.Running:
pass
QCoreApplication.processEvents()
while QgsApplication.taskManager().countActiveTasks() > 0:
QCoreApplication.processEvents()

@@ -162,7 +162,7 @@ def finished_no_val(e):
task = QgsTask.fromFunction('test task', run_no_result, on_finished=finished_no_val)
QgsApplication.taskManager().addTask(task)
while task.status() not in [QgsTask.Complete, QgsTask.Terminated]:
pass
QCoreApplication.processEvents()
while QgsApplication.taskManager().countActiveTasks() > 0:
QCoreApplication.processEvents()

@@ -183,7 +183,7 @@ def finished_fail(e):
task = QgsTask.fromFunction('test task', run_fail, on_finished=finished_fail)
QgsApplication.taskManager().addTask(task)
while task.status() not in [QgsTask.Complete, QgsTask.Terminated]:
pass
QCoreApplication.processEvents()
while QgsApplication.taskManager().countActiveTasks() > 0:
QCoreApplication.processEvents()

@@ -206,7 +206,7 @@ def finished_fail(e):
QgsApplication.taskManager().addTask(task)
task.cancel()
while task.status() not in [QgsTask.Complete, QgsTask.Terminated]:
pass
QCoreApplication.processEvents()
while QgsApplication.taskManager().countActiveTasks() > 0:
QCoreApplication.processEvents()

@@ -228,7 +228,7 @@ def finished_single_value_result(e, value):
task = QgsTask.fromFunction('test task', run_single_val_result, on_finished=finished_single_value_result)
QgsApplication.taskManager().addTask(task)
while task.status() not in [QgsTask.Complete, QgsTask.Terminated]:
pass
QCoreApplication.processEvents()
while QgsApplication.taskManager().countActiveTasks() > 0:
QCoreApplication.processEvents()

@@ -252,7 +252,7 @@ def finished_multiple_value_result(e, results):
task = QgsTask.fromFunction('test task', run_multiple_val_result, on_finished=finished_multiple_value_result)
QgsApplication.taskManager().addTask(task)
while task.status() not in [QgsTask.Complete, QgsTask.Terminated]:
pass
QCoreApplication.processEvents()
while QgsApplication.taskManager().countActiveTasks() > 0:
QCoreApplication.processEvents()

0 comments on commit c2a4ad4

Please sign in to comment.
You can’t perform that action at this time.