[pygobject] Skip instead of fail tests which need Pango, Atk, Gdk, Gtk
- From: Martin Pitt <martinpitt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] Skip instead of fail tests which need Pango, Atk, Gdk, Gtk
- Date: Tue, 31 Jul 2012 15:17:13 +0000 (UTC)
commit 8fb18c62d9c7faff38df3886cb4289b618c81b85
Author: Martin Pitt <martinpitt gnome org>
Date: Tue Jul 31 13:13:21 2012 +0200
Skip instead of fail tests which need Pango, Atk, Gdk, Gtk
On initial jhbuild bootstrap or restricted environments, the Pango, Atk, Gdk,
and Gtk typelibs might not be available. Skip tests which need these instead of
failing the testsuite.
tests/test_atoms.py | 7 ++++++-
tests/test_everything.py | 9 ++++++++-
tests/test_overrides.py | 32 ++++++++++++++++++++++++++------
tests/test_pygtkcompat.py | 30 ++++++++++++++++++++----------
4 files changed, 60 insertions(+), 18 deletions(-)
---
diff --git a/tests/test_atoms.py b/tests/test_atoms.py
index 851368f..a59d15a 100644
--- a/tests/test_atoms.py
+++ b/tests/test_atoms.py
@@ -1,8 +1,13 @@
import unittest
-from gi.repository import Gdk, Gtk
+try:
+ from gi.repository import Atk, Gdk, Gtk
+ (Atk, Gdk) # pyflakes
+except:
+ Gdk = None
+ unittest skipUnless(Gdk, 'Gdk not available')
class TestGdkAtom(unittest.TestCase):
def test_create(self):
atom = Gdk.Atom.intern('my_string', False)
diff --git a/tests/test_everything.py b/tests/test_everything.py
index 728d58a..3cf98fa 100644
--- a/tests/test_everything.py
+++ b/tests/test_everything.py
@@ -15,12 +15,18 @@ try:
except ImportError:
has_cairo = False
+#import gi
from gi.repository import GObject
from gi.repository import GLib
from gi.repository import Gio
-from gi.repository import Gtk
from gi.repository import Regress as Everything
+try:
+ from gi.repository import Gtk
+ Gtk # pyflakes
+except:
+ Gtk = None
+
if sys.version_info < (3, 0):
UNICHAR = "\xe2\x99\xa5"
PY2_UNICODE_UNICHAR = unicode(UNICHAR, 'UTF-8')
@@ -676,6 +682,7 @@ class TestSignals(unittest.TestCase):
class TestPango(unittest.TestCase):
+ @unittest.skipUnless(Gtk, 'Gtk not available')
def test_cairo_font_options(self):
screen = Gtk.Window().get_screen()
font_opts = screen.get_font_options()
diff --git a/tests/test_overrides.py b/tests/test_overrides.py
index cea3e34..44ed3b9 100644
--- a/tests/test_overrides.py
+++ b/tests/test_overrides.py
@@ -8,15 +8,32 @@ sys.path.insert(0, "../")
from compathelper import _long, _unicode, _bytes
+import gi.overrides as overrides
+import gi.types
from gi.repository import GLib
from gi.repository import GObject
-from gi.repository import Gdk
-from gi.repository import Gtk
from gi.repository import Gio
-from gi.repository import Pango
-from gi.repository import GdkPixbuf
-import gi.overrides as overrides
-import gi.types
+
+try:
+ from gi.repository import GdkPixbuf
+ GdkPixbuf # pyflakes
+except ImportError:
+ GdkPixbuf = None
+
+try:
+ from gi.repository import Atk, Pango
+ (Atk, Pango) # pyflakes
+except ImportError:
+ Pango = None
+
+Gtk = None
+if Pango:
+ try:
+ from gi.repository import Gdk
+ from gi.repository import Gtk
+ Gtk # pyflakes
+ except ImportError:
+ Gtk = None
class TestRegistry(unittest.TestCase):
@@ -470,6 +487,7 @@ class TestGLib(unittest.TestCase):
self.assertEqual(repr(v), "GLib.Variant('(is)', (1, 'somestring'))")
+ unittest skipUnless(Pango, 'Pango not available')
class TestPango(unittest.TestCase):
def test_default_font_description(self):
@@ -491,6 +509,7 @@ class TestPango(unittest.TestCase):
self.assertEqual(layout.get_text(), "Foobar")
+ unittest skipUnless(Gtk, 'Gtk not available')
class TestGdk(unittest.TestCase):
def test_constructor(self):
@@ -598,6 +617,7 @@ class TestGdk(unittest.TestCase):
self.assertRaises(ValueError, Gdk.Cursor, 1, 2, 3)
+ unittest skipUnless(Gtk, 'Gtk not available')
class TestGtk(unittest.TestCase):
def test_container(self):
diff --git a/tests/test_pygtkcompat.py b/tests/test_pygtkcompat.py
index 245ee67..37d208d 100644
--- a/tests/test_pygtkcompat.py
+++ b/tests/test_pygtkcompat.py
@@ -6,36 +6,46 @@ import unittest
import sys
sys.path.insert(0, "../")
-from gi.repository import Gdk
-from gi.repository import Gtk
+try:
+ from gi.repository import Pango
+ from gi.repository import Atk
+ from gi.repository import Gdk
+ from gi.repository import Gtk
+ (Atk, Gtk, Pango) # pyflakes
-import gi.pygtkcompat
+ import gi.pygtkcompat
-gi.pygtkcompat.enable()
-gi.pygtkcompat.enable_gtk(version='3.0')
+ gi.pygtkcompat.enable()
+ gi.pygtkcompat.enable_gtk(version='3.0')
-import atk
-import pango
-import pangocairo
-import gtk
-import gtk.gdk
+ import atk
+ import pango
+ import pangocairo
+ import gtk
+ import gtk.gdk
+except ImportError:
+ Gtk = None
+ unittest skipUnless(Gtk, 'Gtk not available')
class TestATKCompat(unittest.TestCase):
def testObject(self):
self.assertTrue(hasattr(atk, 'Object'))
+ unittest skipUnless(Gtk, 'Gtk not available')
class TestPangoCompat(unittest.TestCase):
def testLayout(self):
self.assertTrue(hasattr(pango, 'Layout'))
+ unittest skipUnless(Gtk, 'Gtk not available')
class TestPangoCairoCompat(unittest.TestCase):
def testErrorUnderlinePath(self):
self.assertTrue(hasattr(pangocairo, 'error_underline_path'))
+ unittest skipUnless(Gtk, 'Gtk not available')
class TestGTKCompat(unittest.TestCase):
def testButtons(self):
self.assertEqual(Gdk._2BUTTON_PRESS, 5)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]