From 45d45e7c2704d68a3008f739e501fa332d326b8b Mon Sep 17 00:00:00 2001 From: Simon Feltman Date: Mon, 3 Mar 2014 04:45:59 -0800 Subject: tests: Conditionalize usage of GTK+ in tests_generictreemodel This allows running make check without GTK+ installed. --- tests/test_generictreemodel.py | 16 +++++++++++++--- 1 file 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() -- cgit v1.2.1