summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Feltman <sfeltman@src.gnome.org>2014-03-03 04:45:59 -0800
committerSimon Feltman <sfeltman@src.gnome.org>2014-03-03 04:45:59 -0800
commit45d45e7c2704d68a3008f739e501fa332d326b8b (patch)
tree759067a6bf9c53507fb4c05439359be2acb39ab3
parent038563ed620e0d966e385a1779455d9b0e148c41 (diff)
downloadpygobject-45d45e7c2704d68a3008f739e501fa332d326b8b.tar.gz
tests: Conditionalize usage of GTK+ in tests_generictreemodel
This allows running make check without GTK+ installed.
-rw-r--r--tests/test_generictreemodel.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/tests/test_generictreemodel.py b/tests/test_generictreemodel.py
index 9fa89fff..6ba71bc5 100644
--- a/tests/test_generictreemodel.py
+++ b/tests/test_generictreemodel.py
@@ -28,9 +28,15 @@ import unittest
# pygobject
from gi.repository import GObject
-from gi.repository import Gtk
-from pygtkcompat.generictreemodel import GenericTreeModel
-from pygtkcompat.generictreemodel import _get_user_data_as_pyobject
+
+try:
+ from gi.repository import Gtk
+ from pygtkcompat.generictreemodel import GenericTreeModel
+ from pygtkcompat.generictreemodel import _get_user_data_as_pyobject
+ has_gtk = True
+except ImportError:
+ GenericTreeModel = object
+ has_gtk = False
class Node(object):
@@ -127,6 +133,7 @@ class TesterModel(GenericTreeModel):
return child.parent()
+@unittest.skipUnless(has_gtk, 'Gtk not available')
class TestReferences(unittest.TestCase):
def setUp(self):
pass
@@ -279,6 +286,7 @@ class TestReferences(unittest.TestCase):
self.assertEqual(ref(), None)
+@unittest.skipUnless(has_gtk, 'Gtk not available')
class TestIteration(unittest.TestCase):
def test_iter_next_root(self):
model = TesterModel()
@@ -306,6 +314,7 @@ class ErrorModel(GenericTreeModel):
pass
+@unittest.skipUnless(has_gtk, 'Gtk not available')
class ExceptHook(object):
"""
Temporarily installs an exception hook in a context which
@@ -337,6 +346,7 @@ class ExceptHook(object):
assert issubclass(got, expected), error_message
+@unittest.skipUnless(has_gtk, 'Gtk not available')
class TestReturnsAfterError(unittest.TestCase):
def setUp(self):
self.model = ErrorModel()