[pitivi/1.0] tests: Make sure the zoom is the same



commit 164a9286071a10198394ce7199f8363867e3dd1d
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Sun Feb 11 01:23:13 2018 +0100

    tests: Make sure the zoom is the same
    
    If a test changes the zoom level, it can affect other tests.
    
    This was causing test_keyframe_toggle to fail:
    
    $ nose2 tests.test_render.TestRender.test_rendering_with_youtube_profile 
tests.test_timeline_elements.TestKeyframeCurve.test_keyframe_toggle  -v

 tests/common.py                 |    4 ++++
 tests/test_timeline_elements.py |   11 ++++++-----
 2 files changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/tests/common.py b/tests/common.py
index d488a18..2fc401e 100644
--- a/tests/common.py
+++ b/tests/common.py
@@ -41,6 +41,7 @@ from pitivi.utils.misc import path_from_uri
 from pitivi.utils.proxy import ProxyingStrategy
 from pitivi.utils.proxy import ProxyManager
 from pitivi.utils.timeline import Selected
+from pitivi.utils.timeline import Zoomable
 
 detect_leaks = os.environ.get("PITIVI_TEST_DETECT_LEAKS", "0") not in ("0", "")
 os.environ["PITIVI_USER_CACHE_DIR"] = tempfile.mkdtemp(suffix="pitiviTestsuite")
@@ -194,6 +195,8 @@ class TestCase(unittest.TestCase, Loggable):
         if detect_leaks:
             self.gctrack()
 
+        self.__zoom_level = Zoomable.getCurrentZoomLevel()
+
     def tearDown(self):
         # don't barf gc info all over the console if we have already failed a
         # test case
@@ -203,6 +206,7 @@ class TestCase(unittest.TestCase, Loggable):
         if detect_leaks:
             self.gccollect()
             self.gcverify()
+        Zoomable.setZoomLevel(self.__zoom_level)
 
     # override run() to save a reference to the test result object
     def run(self, result=None):
diff --git a/tests/test_timeline_elements.py b/tests/test_timeline_elements.py
index 3b954f7..0a4bdb0 100644
--- a/tests/test_timeline_elements.py
+++ b/tests/test_timeline_elements.py
@@ -118,6 +118,7 @@ class TestKeyframeCurve(BaseTestTimeline):
             values = [item.timestamp for item in control_source.get_all()]
             self.assertEqual(values, [inpoint, inpoint + duration])
 
+    # pylint: disable=too-many-statements
     def check_keyframe_ui_toggle(self, ges_clip, timeline_container):
         """Checks keyframes toggling by click events."""
         timeline = timeline_container.timeline
@@ -141,11 +142,11 @@ class TestKeyframeCurve(BaseTestTimeline):
             x, y = keyframe_curve._ax.transData.transform((xdata, ydata))
 
             event = MouseEvent(
-                name = "button_press_event",
-                canvas = keyframe_curve,
-                x = x,
-                y = y,
-                button = 1
+                name="button_press_event",
+                canvas=keyframe_curve,
+                x=x,
+                y=y,
+                button=1
             )
             event.guiEvent = Gdk.Event.new(Gdk.EventType.BUTTON_PRESS)
             keyframe_curve._mpl_button_press_event_cb(event)


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