[pitivi] tests: Exit whenever an unhandled backtrace happens



commit 748369ff5953d566fe72aa4b569a2cd333b5719f
Author: Thibault Saunier <tsaunier igalia com>
Date:   Wed Jun 13 11:17:31 2018 -0400

    tests: Exit whenever an unhandled backtrace happens
    
    And fix all tests.
    
    Fixes #2207

 pitivi/timeline/previewers.py |  3 +--
 tests/common.py               | 11 +++++++++++
 tests/test_media_library.py   |  3 ++-
 tests/test_project.py         |  7 ++++++-
 4 files changed, 20 insertions(+), 4 deletions(-)
---
diff --git a/pitivi/timeline/previewers.py b/pitivi/timeline/previewers.py
index b167e033..26f2afa6 100644
--- a/pitivi/timeline/previewers.py
+++ b/pitivi/timeline/previewers.py
@@ -997,7 +997,7 @@ class AudioPreviewer(Previewer, Zoomable, Loggable):
         faked = self.pipeline.get_by_name("faked")
         faked.props.sync = True
         self._wavebin = self.pipeline.get_by_name("wave")
-        asset = self.ges_elem.get_parent().get_asset()
+        asset = self.ges_elem.get_asset().get_filesource_asset()
         self._wavebin.props.uri = asset.get_id()
         self._wavebin.props.duration = asset.get_duration()
         decode = self.pipeline.get_by_name("decode")
@@ -1005,7 +1005,6 @@ class AudioPreviewer(Previewer, Zoomable, Loggable):
         bus = self.pipeline.get_bus()
         bus.add_signal_watch()
 
-        asset = self.ges_elem.get_parent().get_asset()
         self.n_samples = asset.get_duration() / SAMPLE_DURATION
         bus.connect("message", self._busMessageCb)
 
diff --git a/tests/common.py b/tests/common.py
index 4a98d03c..070e51ec 100644
--- a/tests/common.py
+++ b/tests/common.py
@@ -23,7 +23,9 @@ import contextlib
 import gc
 import os
 import shutil
+import sys
 import tempfile
+import traceback
 import unittest
 from unittest import mock
 
@@ -47,6 +49,15 @@ from pitivi.utils.proxy import ProxyManager
 from pitivi.utils.timeline import Selected
 from pitivi.utils.timeline import Zoomable
 
+
+def handle_uncaught_exception(exctype, value, trace):
+    traceback.print_tb(trace)
+    print(value, file=sys.stderr)
+    sys.exit(1)
+
+
+sys.excepthook = handle_uncaught_exception
+
 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/test_media_library.py b/tests/test_media_library.py
index 52ed3911..3fcf8777 100644
--- a/tests/test_media_library.py
+++ b/tests/test_media_library.py
@@ -219,7 +219,8 @@ class TestMediaLibrary(BaseTestMediaLibrary):
     def test_supported_out_of_container_audio(self):
         sample = "mp3_sample.mp3"
         with common.cloned_sample(sample):
-            self.check_import([sample], check_no_transcoding=True)
+            self.check_import([sample], check_no_transcoding=True,
+                proxying_strategy=ProxyingStrategy.AUTOMATIC)
 
     def test_missing_uri_displayed(self):
         with common.cloned_sample():
diff --git a/tests/test_project.py b/tests/test_project.py
index 8aed5f37..bfb7f8bd 100644
--- a/tests/test_project.py
+++ b/tests/test_project.py
@@ -62,7 +62,11 @@ class TestProjectManager(common.TestCase):
 
     def setUp(self):
         super(TestProjectManager, self).setUp()
-        app = mock.MagicMock()
+        self.setupApp()
+
+    def setupApp(self, app=None):
+        if not app:
+            app = mock.MagicMock()
         self.manager = ProjectManager(app)
         self.listener = ProjectManagerListener(self.manager)
         self.signals = self.listener.signals
@@ -98,6 +102,7 @@ class TestProjectManager(common.TestCase):
         self.assertEqual("new-project-loaded", name, self.signals)
 
     def testMissingUriForwarded(self):
+        self.setupApp(app=common.create_pitivi_mock())
         mainloop = common.create_main_loop()
 
         def missingUriCb(self, project, error, clip_asset, result):


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