[pitivi] tests: Fix testInitialization flakiness



commit 5e7634487a33729591f87372d8155a0bc2759cd1
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Tue Apr 5 03:19:32 2016 +0200

    tests: Fix testInitialization flakiness
    
    It was flaky because the assets were being discovered in a random order.
    
    Differential Revision: https://phabricator.freedesktop.org/D886

 tests/test_project.py |   25 ++++++++++++++-----------
 1 files changed, 14 insertions(+), 11 deletions(-)
---
diff --git a/tests/test_project.py b/tests/test_project.py
index c66b64a..f5f15ad 100644
--- a/tests/test_project.py
+++ b/tests/test_project.py
@@ -17,6 +17,7 @@
 # License along with this program; if not, write to the
 # Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 # Boston, MA 02110-1301, USA.
+import collections
 import os
 import tempfile
 import time
@@ -24,7 +25,6 @@ from unittest import mock
 from unittest import TestCase
 
 from gi.repository import GES
-from gi.repository import GLib
 from gi.repository import Gst
 
 from pitivi.project import Project
@@ -372,26 +372,29 @@ class TestProjectSettings(common.TestCase):
 
     def testInitialization(self):
         mainloop = common.create_main_loop()
+        uris = collections.deque([
+            common.getSampleUri("flat_colour1_640x480.png"),
+            common.getSampleUri("tears_of_steel.webm"),
+            common.getSampleUri("1sec_simpsons_trailer.mp4")])
 
-        def loadedCb(project, timeline, uris):
-            project.addUris(uris)
+        def loaded_cb(project, timeline):
+            project.addUris([uris.popleft()])
 
-        def progressCb(project, progress, estimated_time):
+        def progress_cb(project, progress, estimated_time):
             if progress == 100:
-                mainloop.quit()
+                if uris:
+                    project.addUris([uris.popleft()])
+                else:
+                    mainloop.quit()
 
         # Create a blank project and add some assets.
         project = _createRealProject()
         self.assertTrue(project._has_default_video_settings)
         self.assertTrue(project._has_default_audio_settings)
 
-        uris = [common.getSampleUri("flat_colour1_640x480.png"),
-                common.getSampleUri("tears_of_steel.webm"),
-                common.getSampleUri("1sec_simpsons_trailer.mp4")]
-        project.connect("loaded", loadedCb, uris)
-        project.connect("asset-loading-progress", progressCb)
+        project.connect_after("loaded", loaded_cb)
+        project.connect_after("asset-loading-progress", progress_cb)
 
-        self.assertTrue(project.createTimeline())
         mainloop.run()
 
         assets = project.list_assets(GES.UriClip)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]