Commit 8fb18c62 authored by Martin Pitt's avatar Martin Pitt
Browse files

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.
parent a2e73c10
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)
......
......@@ -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()
......
......@@ -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):
......
......@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment