@@ -35,9 +35,12 @@ def setUp(self):
35
35
self .testDataDir = unitTestDataPath ()
36
36
self .success = False
37
37
self .fail = False
38
+ self .ids = None
39
+ self .task = None
38
40
39
41
def onSuccess (self ):
40
42
self .success = True
43
+ self .ids = [f .id () for f in self .task .layer ().getFeatures ()]
41
44
42
45
def onFail (self ):
43
46
self .fail = True
@@ -49,23 +52,22 @@ def test(self):
49
52
50
53
df = QgsVirtualLayerDefinition ()
51
54
df .setQuery ('select * from "françéà"' )
52
- task = QgsVirtualLayerTask (df )
55
+ self . task = QgsVirtualLayerTask (df )
53
56
54
- ids = [f .id () for f in task .layer ().getFeatures ()]
57
+ ids = [f .id () for f in self . task .layer ().getFeatures ()]
55
58
self .assertEqual (len (ids ), 0 )
56
59
57
- task .taskCompleted .connect (self .onSuccess )
58
- task .taskTerminated .connect (self .onFail )
60
+ self . task .taskCompleted .connect (self .onSuccess )
61
+ self . task .taskTerminated .connect (self .onFail )
59
62
60
- QgsApplication .taskManager ().addTask (task )
63
+ QgsApplication .taskManager ().addTask (self . task )
61
64
while not self .success and not self .fail :
62
65
QCoreApplication .processEvents ()
63
66
64
67
self .assertTrue (self .success )
65
68
self .assertFalse (self .fail )
66
69
67
- ids = [f .id () for f in task .layer ().getFeatures ()]
68
- self .assertEqual (len (ids ), 4 )
70
+ self .assertEqual (len (self .ids ), 4 )
69
71
70
72
71
73
if __name__ == '__main__' :
0 commit comments