[pitivi/1.0] tests: Make some fatal GLib logs failures



commit 089fcf606cc44c5dc2558dc70bbe598b82cadc53
Author: Thibault Saunier <tsaunier igalia com>
Date:   Sun Jul 1 14:39:57 2018 -0400

    tests: Make some fatal GLib logs failures
    
    Not simply using fatal-criticals as some criticals are outside of
    control on the CI server (no dbus running there)
    
    It requires patches in GES 1.14.2, we will bump the dep when released.

 build/flatpak/pitivi-flatpak |  3 ++-
 tests/common.py              | 10 ++++++++++
 tests/ptv_testsuite.py       |  5 +++--
 tests/test_mainwindow.py     |  7 +++----
 tests/test_pipeline.py       |  2 +-
 5 files changed, 19 insertions(+), 8 deletions(-)
---
diff --git a/build/flatpak/pitivi-flatpak b/build/flatpak/pitivi-flatpak
index 65f86bcb..a4d10dad 100755
--- a/build/flatpak/pitivi-flatpak
+++ b/build/flatpak/pitivi-flatpak
@@ -598,7 +598,8 @@ class PitiviFlatpak:  # pylint: disable=too-many-instance-attributes
         if not args:
             return
 
-        flatpak_command = ["flatpak", "build", "--socket=x11",
+        flatpak_command = ["flatpak", "build", "--socket=x11", "--socket=wayland",
+                           "--talk-name=org.freedesktop.Flatpak",
                            "--socket=session-bus", "--socket=pulseaudio",
                            "--share=network", "--env=PITIVI_DEVELOPMENT=1",
                            "--env=PYTHONUSERBASE=/app/",
diff --git a/tests/common.py b/tests/common.py
index 070e51ec..1dc290c4 100644
--- a/tests/common.py
+++ b/tests/common.py
@@ -58,6 +58,16 @@ def handle_uncaught_exception(exctype, value, trace):
 
 sys.excepthook = handle_uncaught_exception
 
+
+def handle_glog(domain, level, message, udata):
+    traceback.print_stack()
+    print("%s - %s" % (domain, message), file=sys.stderr)
+    sys.exit(1)
+
+
+for category in ["GStreamer", "Gtk", "Gdk", "GLib-GObject", "GES"]:
+    GLib.log_set_handler(category, GLib.LogLevelFlags.LEVEL_CRITICAL, handle_glog, None)
+
 detect_leaks = os.environ.get("PITIVI_TEST_DETECT_LEAKS", "0") not in ("0", "")
 os.environ["PITIVI_USER_CACHE_DIR"] = tempfile.mkdtemp(suffix="pitiviTestsuite")
 
diff --git a/tests/ptv_testsuite.py b/tests/ptv_testsuite.py
index 8ce1d5b8..950f2e90 100644
--- a/tests/ptv_testsuite.py
+++ b/tests/ptv_testsuite.py
@@ -51,8 +51,9 @@ def setup_tests(test_manager, options):
     testsuites = loader.discover(CDIR)
     for testsuite in testsuites:
         for _tests in testsuite:
-            if isinstance(_tests, unittest.loader._FailedTest):
-                print(_tests._exception)
+
+            if isinstance(_tests, unittest.loader._FailedTest):  # pylint: disable=protected-access
+                print(_tests._exception)  # pylint: disable=protected-access
                 continue
             for test in _tests:
                 test_manager.add_test(PitiviTest(
diff --git a/tests/test_mainwindow.py b/tests/test_mainwindow.py
index bebf9358..ad3f7a68 100644
--- a/tests/test_mainwindow.py
+++ b/tests/test_mainwindow.py
@@ -30,6 +30,7 @@ from pitivi.utils.misc import disconnectAllByFunc
 from tests import common
 
 
+# pylint: disable=protected-access
 class TestMainWindow(common.TestCase):
     """Tests for the MainWindow class."""
 
@@ -60,6 +61,8 @@ class TestMainWindow(common.TestCase):
         app.project_manager = ProjectManager(app)
         mainwindow = MainWindow(app)
         mainwindow.viewer = mock.MagicMock()
+        mainwindow.medialibrary._import_warning_infobar = mock.MagicMock()
+        mainwindow.clipconfig.effect_expander._infobar = mock.MagicMock()
 
         def __pm_missing_uri_cb(project_manager, project, error, asset):
             nonlocal mainloop
@@ -77,7 +80,6 @@ class TestMainWindow(common.TestCase):
                     return_value=Gtk.ResponseType.CLOSE)
 
                 # Call the actual callback
-                # pylint: disable=protected-access
                 app.proxy_manager.checkProxyLoadingSucceeded =  \
                     mock.MagicMock(return_value=has_proxy)
 
@@ -88,17 +90,14 @@ class TestMainWindow(common.TestCase):
                 self.assertTrue(dialog.return_value.run.called)
                 self.assertEqual(failed_cb.called, not has_proxy)
 
-            # pylint: disable=protected-access
             app.project_manager.connect("missing-uri",
                                         mainwindow._projectManagerMissingUriCb)
-            # pylint: disable=protected-access
             app.project_manager.connect("new-project-failed",
                                         mainwindow._projectManagerNewProjectFailedCb)
 
             mainwindow.destroy()
             mainloop.quit()
 
-        # pylint: disable=protected-access
         disconnectAllByFunc(app.project_manager,
                             mainwindow._projectManagerMissingUriCb)
         disconnectAllByFunc(app.project_manager,
diff --git a/tests/test_pipeline.py b/tests/test_pipeline.py
index 7cd15a7d..e9d44255 100644
--- a/tests/test_pipeline.py
+++ b/tests/test_pipeline.py
@@ -75,7 +75,7 @@ class TestPipeline(common.TestCase):
 
     def test_async_done_not_received(self):
         """Checks the recovery when the ASYNC_DONE message timed out."""
-        ges_timeline = GES.Timeline()
+        ges_timeline = GES.Timeline.new()
         self.assertTrue(ges_timeline.add_track(GES.VideoTrack.new()))
         ges_layer = ges_timeline.append_layer()
         uri = common.get_sample_uri("tears_of_steel.webm")


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