[pitivi/1.0] tests: Switch most of the tests to use common.TestCase
- From: Alexandru Băluț <alexbalut src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi/1.0] tests: Switch most of the tests to use common.TestCase
- Date: Sun, 11 Feb 2018 02:03:45 +0000 (UTC)
commit b480bc6768dc69de74eff84db22280f538fff5c8
Author: Alexandru Băluț <alexandru balut gmail com>
Date: Sun Feb 11 02:40:52 2018 +0100
tests: Switch most of the tests to use common.TestCase
tests/test_clipproperties.py | 5 ++---
tests/test_effects.py | 17 +++++++----------
tests/test_misc.py | 14 ++++++--------
tests/test_prefs.py | 5 ++---
tests/test_preset.py | 6 +++---
tests/test_project.py | 6 +++---
tests/test_settings.py | 4 ++--
tests/test_shortcuts.py | 4 ++--
tests/test_timeline_elements.py | 16 +++++++---------
tests/test_timeline_layer.py | 12 +++++-------
tests/test_undo.py | 11 ++++++-----
tests/test_undo_project.py | 5 ++---
tests/test_undo_timeline.py | 5 ++---
tests/test_utils_timeline.py | 5 ++---
tests/test_widgets.py | 7 +++----
15 files changed, 54 insertions(+), 68 deletions(-)
---
diff --git a/tests/test_clipproperties.py b/tests/test_clipproperties.py
index b0f55cf..0147ed4 100644
--- a/tests/test_clipproperties.py
+++ b/tests/test_clipproperties.py
@@ -18,14 +18,13 @@
# Boston, MA 02110-1301, USA.
"""Tests for the pitivi.clipproperties module."""
# pylint: disable=protected-access,no-self-use,too-many-locals
-import unittest
-
from gi.repository import Gtk
from pitivi.clipproperties import EffectProperties
+from tests import common
-class EffectPropertiesTest(unittest.TestCase):
+class EffectPropertiesTest(common.TestCase):
"""Tests for the EffectProperties class."""
def test_calculate_effect_priority(self):
diff --git a/tests/test_effects.py b/tests/test_effects.py
index 3800be5..bf99562 100644
--- a/tests/test_effects.py
+++ b/tests/test_effects.py
@@ -17,22 +17,19 @@
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301, USA.
"""Tests for the effects module."""
-import unittest
-
from gi.repository import GES
from pitivi.effects import AUDIO_EFFECT
from pitivi.effects import EffectInfo
from pitivi.effects import VIDEO_EFFECT
-from tests.common import create_timeline_container
-from tests.common import get_sample_uri
+from tests import common
-class EffectInfoTest(unittest.TestCase):
+class EffectInfoTest(common.TestCase):
"""Tests for the EffectInfo class."""
def test_bin_description(self):
- """Tests the bin_description property."""
+ """Checks the bin_description property."""
effect_info = EffectInfo("name", None, None, None, None)
self.assertEqual(effect_info.bin_description, "name")
@@ -40,18 +37,18 @@ class EffectInfoTest(unittest.TestCase):
self.assertEqual(effect_info.bin_description, "glupload ! glname ! gldownload")
def test_name_from_bin_description(self):
- """Tests the name_from_bin_description method."""
+ """Checks the name_from_bin_description method."""
self.assertEqual(EffectInfo.name_from_bin_description("name"), "name")
self.assertEqual(EffectInfo.name_from_bin_description("glupload ! glname ! gldownload"), "glname")
def test_good_for_track_element(self):
- """Tests the good_for_track_element method."""
- uri = get_sample_uri("tears_of_steel.webm")
+ """Checks the good_for_track_element method."""
+ uri = common.get_sample_uri("tears_of_steel.webm")
asset = GES.UriClipAsset.request_sync(uri)
ges_clip = asset.extract()
# Add the clip to a timeline so it gets tracks.
- ges_timeline = create_timeline_container().timeline.ges_timeline
+ ges_timeline = common.create_timeline_container().timeline.ges_timeline
ges_timeline.append_layer()
ges_layer, = ges_timeline.get_layers()
ges_layer.add_clip(ges_clip)
diff --git a/tests/test_misc.py b/tests/test_misc.py
index 244b3cb..bd4dc04 100644
--- a/tests/test_misc.py
+++ b/tests/test_misc.py
@@ -19,21 +19,19 @@
"""Tests for the utils.misc module."""
# pylint: disable=protected-access,no-self-use
import os
-import unittest
from gi.repository import Gst
from pitivi.utils.misc import PathWalker
-from tests.common import create_main_loop
-from tests.common import get_sample_uri
+from tests import common
-class PathWalkerTest(unittest.TestCase):
+class PathWalkerTest(common.TestCase):
"""Tests for the `PathWalker` class."""
def _scan(self, uris):
"""Uses the PathWalker to scan URIs."""
- mainloop = create_main_loop()
+ mainloop = common.create_main_loop()
received_uris = []
def done_cb(uris): # pylint: disable=missing-docstring
@@ -46,9 +44,9 @@ class PathWalkerTest(unittest.TestCase):
def test_scanning(self):
"""Checks the scanning of the URIs."""
- valid_uri = get_sample_uri("tears_of_steel.webm")
+ valid_uri = common.get_sample_uri("tears_of_steel.webm")
uris = self._scan([valid_uri,
- get_sample_uri("missing.webm"),
+ common.get_sample_uri("missing.webm"),
"http://pitivi.org/very_real.webm"])
self.assertEqual(len(uris), 1, uris)
self.assertIn(valid_uri, uris)
@@ -60,5 +58,5 @@ class PathWalkerTest(unittest.TestCase):
uris = [valid_dir_uri]
received_uris = self._scan(uris)
self.assertGreater(len(received_uris), 1, received_uris)
- valid_uri = get_sample_uri("tears_of_steel.webm")
+ valid_uri = common.get_sample_uri("tears_of_steel.webm")
self.assertIn(valid_uri, received_uris)
diff --git a/tests/test_prefs.py b/tests/test_prefs.py
index 8cc5430..8884716 100644
--- a/tests/test_prefs.py
+++ b/tests/test_prefs.py
@@ -16,12 +16,11 @@
# 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 unittest
-
from pitivi.dialogs.prefs import PreferencesDialog
+from tests import common
-class PreferencesDialogTest(unittest.TestCase):
+class PreferencesDialogTest(common.TestCase):
def testNumeric(self):
section = list(PreferencesDialog.section_names.keys())[0]
diff --git a/tests/test_preset.py b/tests/test_preset.py
index 3ecdc14..4782a6a 100644
--- a/tests/test_preset.py
+++ b/tests/test_preset.py
@@ -21,11 +21,11 @@
import os.path
import shutil
import tempfile
-from unittest import TestCase
from pitivi.preset import AudioPresetManager
from pitivi.preset import PresetManager
from pitivi.utils.system import System
+from tests import common
def clearPresetManagerPaths(preset_manager):
@@ -49,7 +49,7 @@ def countUserPresets(preset_manager):
return countJsonFilesIn(preset_manager.user_path)
-class TestPresetBasics(TestCase):
+class TestPresetBasics(common.TestCase):
def setUp(self):
self.manager = PresetManager(None, tempfile.mkdtemp(), System())
@@ -108,7 +108,7 @@ class TestPresetBasics(TestCase):
self.assertEqual('New preset 3', new_preset3)
-class TestAudioPresetsIO(TestCase):
+class TestAudioPresetsIO(common.TestCase):
def setUp(self):
self.manager = AudioPresetManager(System())
diff --git a/tests/test_project.py b/tests/test_project.py
index 8daaea2..a03c94b 100644
--- a/tests/test_project.py
+++ b/tests/test_project.py
@@ -22,7 +22,6 @@ import os
import tempfile
import time
from unittest import mock
-from unittest import TestCase
from gi.repository import GES
from gi.repository import Gst
@@ -59,9 +58,10 @@ class ProjectManagerListener(object):
return True
-class TestProjectManager(TestCase):
+class TestProjectManager(common.TestCase):
def setUp(self):
+ super(TestProjectManager, self).setUp()
app = mock.MagicMock()
self.manager = ProjectManager(app)
self.listener = ProjectManagerListener(self.manager)
@@ -604,7 +604,7 @@ class TestProjectSettings(common.TestCase):
self.assertFalse(project._has_default_audio_settings)
-class TestExportSettings(TestCase):
+class TestExportSettings(common.TestCase):
def test_master_attributes(self):
self._check_master_attribute("muxer", dependant_attr="containersettings")
diff --git a/tests/test_settings.py b/tests/test_settings.py
index a948cb2..8af5b1f 100644
--- a/tests/test_settings.py
+++ b/tests/test_settings.py
@@ -20,14 +20,14 @@
# pylint: disable=missing-docstring
import os
import tempfile
-import unittest
from unittest import mock
from pitivi.settings import ConfigError
from pitivi.settings import GlobalSettings
+from tests import common
-class TestGlobalSettings(unittest.TestCase):
+class TestGlobalSettings(common.TestCase):
"""Tests the GlobalSettings class."""
def setUp(self):
diff --git a/tests/test_shortcuts.py b/tests/test_shortcuts.py
index d77b3e8..5100fd7 100644
--- a/tests/test_shortcuts.py
+++ b/tests/test_shortcuts.py
@@ -20,12 +20,12 @@
import os
import tempfile
from unittest import mock
-from unittest import TestCase
from pitivi.shortcuts import ShortcutsManager
+from tests import common
-class TestShortcutsManager(TestCase):
+class TestShortcutsManager(common.TestCase):
"""Tests for the ShortcutsManager."""
def test_groups(self):
diff --git a/tests/test_timeline_elements.py b/tests/test_timeline_elements.py
index 0a4bdb0..2d80b5f 100644
--- a/tests/test_timeline_elements.py
+++ b/tests/test_timeline_elements.py
@@ -19,7 +19,6 @@
"""Tests for the timeline.elements module."""
# pylint: disable=protected-access,no-self-use,too-many-locals
from unittest import mock
-from unittest import TestCase
from gi.overrides import GObject
from gi.repository import Gdk
@@ -28,9 +27,8 @@ from matplotlib.backend_bases import MouseEvent
from pitivi.timeline.elements import GES_TYPE_UI_TYPE
from pitivi.undo.undo import UndoableActionLog
-from tests.common import create_test_clip
-from tests.common import create_timeline_container
from tests.test_timeline_timeline import BaseTestTimeline
+from tests import common
class TestKeyframeCurve(BaseTestTimeline):
@@ -38,7 +36,7 @@ class TestKeyframeCurve(BaseTestTimeline):
def test_keyframe_toggle(self):
"""Checks keyframes toggling at the playhead position."""
- timeline_container = create_timeline_container()
+ timeline_container = common.create_timeline_container()
timeline_container.app.action_log = UndoableActionLog()
timeline = timeline_container.timeline
ges_layer = timeline.ges_timeline.append_layer()
@@ -46,7 +44,7 @@ class TestKeyframeCurve(BaseTestTimeline):
ges_clip2 = self.add_clip(ges_layer, 10)
ges_clip3 = self.add_clip(ges_layer, 20, inpoint=100)
# For variety, add TitleClip to the list of clips.
- ges_clip4 = create_test_clip(GES.TitleClip)
+ ges_clip4 = common.create_test_clip(GES.TitleClip)
ges_clip4.props.start = 30
ges_clip4.props.duration = 4.5
ges_layer.add_clip(ges_clip4)
@@ -188,7 +186,7 @@ class TestKeyframeCurve(BaseTestTimeline):
def test_no_clip_selected(self):
"""Checks nothing happens when no clip is selected."""
- timeline_container = create_timeline_container()
+ timeline_container = common.create_timeline_container()
# Make sure this does not raise any exception
timeline_container._keyframe_cb(None, None)
@@ -198,7 +196,7 @@ class TestVideoSource(BaseTestTimeline):
def test_video_source_scaling(self):
"""Checks the size of the scaled clips."""
- timeline_container = create_timeline_container()
+ timeline_container = common.create_timeline_container()
timeline = timeline_container.timeline
project = timeline.app.project_manager.current_project
@@ -254,7 +252,7 @@ class TestVideoSource(BaseTestTimeline):
def test_rotation(self):
"""Checks the size of the clips flipped 90 degrees."""
- timeline_container = create_timeline_container()
+ timeline_container = common.create_timeline_container()
timeline = timeline_container.timeline
clip = self.addClipsSimple(timeline, 1)[0]
@@ -298,7 +296,7 @@ class TestVideoSource(BaseTestTimeline):
self.assertEqual(height, 400)
-class TestClip(TestCase):
+class TestClip(common.TestCase):
"""Tests for the Clip class."""
def test_clip_subclasses(self):
diff --git a/tests/test_timeline_layer.py b/tests/test_timeline_layer.py
index 911b80b..0e969fc 100644
--- a/tests/test_timeline_layer.py
+++ b/tests/test_timeline_layer.py
@@ -21,12 +21,10 @@ from unittest import mock
from gi.repository import GES
from pitivi.timeline.layer import Layer
-from tests.common import create_timeline_container
-from tests.common import get_sample_uri
-from tests.common import TestCase
+from tests import common
-class TestLayerControl(TestCase):
+class TestLayerControl(common.TestCase):
def test_name(self):
timeline = mock.MagicMock()
@@ -51,15 +49,15 @@ class TestLayerControl(TestCase):
self.assertEqual(layer.getName(), "Layer 0x")
-class TestLayer(TestCase):
+class TestLayer(common.TestCase):
def test_check_media_types_when_no_control_ui(self):
ges_layer = GES.Layer()
- png = get_sample_uri("flat_colour1_640x480.png")
+ png = common.get_sample_uri("flat_colour1_640x480.png")
video_clip = GES.UriClipAsset.request_sync(png).extract()
self.assertTrue(ges_layer.add_clip(video_clip))
self.assertEqual(len(ges_layer.get_clips()), 1)
- timeline_container = create_timeline_container()
+ timeline_container = common.create_timeline_container()
timeline = timeline_container.timeline
# This will add widgets for the clips in ges_layer and
# the layer will use checkMediaTypes which updates the
diff --git a/tests/test_undo.py b/tests/test_undo.py
index 408458a..34de3f0 100644
--- a/tests/test_undo.py
+++ b/tests/test_undo.py
@@ -17,7 +17,6 @@
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301, USA.
from unittest import mock
-from unittest import TestCase
from gi.repository import GES
@@ -28,9 +27,10 @@ from pitivi.undo.undo import UndoableActionLog
from pitivi.undo.undo import UndoableActionStack
from pitivi.undo.undo import UndoError
from pitivi.undo.undo import UndoWrongStateError
+from tests import common
-class TestUndoableActionStack(TestCase):
+class TestUndoableActionStack(common.TestCase):
def testUndoDo(self):
"""
@@ -79,7 +79,7 @@ class TestUndoableActionStack(TestCase):
self.assertEqual(action3.undo.call_count, 1)
-class TestUndoableActionLog(TestCase):
+class TestUndoableActionLog(common.TestCase):
def setUp(self):
self.log = UndoableActionLog()
@@ -407,7 +407,8 @@ class TestUndoableActionLog(TestCase):
self.assertEqual(len(self.log.undo_stacks), 0)
self.assertEqual(len(self.log.redo_stacks), 0)
-class TestGObjectObserver(TestCase):
+
+class TestGObjectObserver(common.TestCase):
def test_property_change(self):
action_log = UndoableActionLog()
@@ -432,7 +433,7 @@ class TestGObjectObserver(TestCase):
self.assertEqual(action.new_value, 4)
-class TestPropertyChangedAction(TestCase):
+class TestPropertyChangedAction(common.TestCase):
def test_expand(self):
stack = UndoableActionStack("good one!")
diff --git a/tests/test_undo_project.py b/tests/test_undo_project.py
index 9141dc7..6f15a22 100644
--- a/tests/test_undo_project.py
+++ b/tests/test_undo_project.py
@@ -16,8 +16,6 @@
# License along with this program; if not, write to the
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301, USA.
-from unittest import TestCase
-
from gi.repository import GES
from gi.repository import Gtk
@@ -25,9 +23,10 @@ from pitivi.project import ProjectSettingsDialog
from tests import common
-class TestProjectUndo(TestCase):
+class TestProjectUndo(common.TestCase):
def setUp(self):
+ super(TestProjectUndo, self).setUp()
self.app = common.create_pitivi()
self.assertTrue(self.app.project_manager.newBlankProject())
diff --git a/tests/test_undo_timeline.py b/tests/test_undo_timeline.py
index f03515e..23e07eb 100644
--- a/tests/test_undo_timeline.py
+++ b/tests/test_undo_timeline.py
@@ -18,8 +18,6 @@
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301, USA.
from unittest import mock
-from unittest import skip
-from unittest import TestCase
from gi.repository import Gdk
from gi.repository import GES
@@ -40,9 +38,10 @@ from pitivi.utils.ui import URI_TARGET_ENTRY
from tests import common
-class BaseTestUndoTimeline(TestCase):
+class BaseTestUndoTimeline(common.TestCase):
def setUp(self):
+ super(BaseTestUndoTimeline, self).setUp()
self.app = common.create_pitivi()
self.app.project_manager.newBlankProject()
diff --git a/tests/test_utils_timeline.py b/tests/test_utils_timeline.py
index 7420c2b..bbc38a8 100644
--- a/tests/test_utils_timeline.py
+++ b/tests/test_utils_timeline.py
@@ -17,7 +17,6 @@
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301, USA.
from unittest import mock
-from unittest import TestCase
from gi.repository import GES
@@ -29,7 +28,7 @@ from pitivi.utils.timeline import UNSELECT
from tests import common
-class TestSelected(TestCase):
+class TestSelected(common.TestCase):
def testBoolEvaluation(self):
selected = Selected()
@@ -42,7 +41,7 @@ class TestSelected(TestCase):
self.assertFalse(selected)
-class TestSelection(TestCase):
+class TestSelection(common.TestCase):
def testBoolEvaluation(self):
clip1 = mock.MagicMock()
diff --git a/tests/test_widgets.py b/tests/test_widgets.py
index d598a04..9c8739a 100644
--- a/tests/test_widgets.py
+++ b/tests/test_widgets.py
@@ -16,8 +16,6 @@
# License along with this program; if not, write to the
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301, USA.
-from unittest import TestCase
-
from gi.repository import Gst
from pitivi.utils.widgets import ChoiceWidget
@@ -28,9 +26,10 @@ from pitivi.utils.widgets import NumericWidget
from pitivi.utils.widgets import PathWidget
from pitivi.utils.widgets import TextWidget
from pitivi.utils.widgets import ToggleWidget
+from tests import common
-class TestWidgets(TestCase):
+class TestWidgets(common.TestCase):
def testConstruction(self):
widgets = (
@@ -63,7 +62,7 @@ class TestWidgets(TestCase):
self.assertNotEqual(bad_value, widget.getWidgetValue())
-class TestFractionWidget(TestCase):
+class TestFractionWidget(common.TestCase):
def test_widget_text(self):
widget = FractionWidget()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]