summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2017-07-12 08:40:57 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2017-07-12 08:41:01 +0900
commitd515c550b1574ab0bdd751ebf31600347ecc396b (patch)
treed25cdf86f8c84ad43e52c94b45b7f8353ed0429a /tests
parent4f476d6ac93c838c034cc2943647dfae3eaf9090 (diff)
downloadpygobject2-d515c550b1574ab0bdd751ebf31600347ecc396b.tar.gz
pygobject2-d515c550b1574ab0bdd751ebf31600347ecc396b.tar.bz2
pygobject2-d515c550b1574ab0bdd751ebf31600347ecc396b.zip
Imported Upstream version 3.11.91
Change-Id: I6a9a58284ff7f0bec0f4afba0c8bb3a909287ce6 Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/test_generictreemodel.py16
-rw-r--r--tests/test_overrides_gtk.py32
-rw-r--r--tests/test_properties.py27
3 files changed, 46 insertions, 29 deletions
diff --git a/tests/test_generictreemodel.py b/tests/test_generictreemodel.py
index 9fa89ff..6ba71bc 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()
diff --git a/tests/test_overrides_gtk.py b/tests/test_overrides_gtk.py
index 210cf45..2a0fd90 100644
--- a/tests/test_overrides_gtk.py
+++ b/tests/test_overrides_gtk.py
@@ -633,26 +633,26 @@ class TestGtk(unittest.TestCase):
@unittest.skipUnless(Gtk, 'Gtk not available')
class TestSignals(unittest.TestCase):
- class WindowWithSizeAllocOverride(Gtk.ScrolledWindow):
- __gsignals__ = {'size-allocate': 'override'}
+ def test_class_closure_override_with_aliased_type(self):
+ class WindowWithSizeAllocOverride(Gtk.ScrolledWindow):
+ __gsignals__ = {'size-allocate': 'override'}
- def __init__(self):
- Gtk.ScrolledWindow.__init__(self)
- self._alloc_called = False
- self._alloc_value = None
- self._alloc_error = None
+ def __init__(self):
+ Gtk.ScrolledWindow.__init__(self)
+ self._alloc_called = False
+ self._alloc_value = None
+ self._alloc_error = None
- def do_size_allocate(self, alloc):
- self._alloc_called = True
- self._alloc_value = alloc
+ def do_size_allocate(self, alloc):
+ self._alloc_called = True
+ self._alloc_value = alloc
- try:
- Gtk.ScrolledWindow.do_size_allocate(self, alloc)
- except Exception as e:
- self._alloc_error = e
+ try:
+ Gtk.ScrolledWindow.do_size_allocate(self, alloc)
+ except Exception as e:
+ self._alloc_error = e
- def test_class_closure_override_with_aliased_type(self):
- win = self.WindowWithSizeAllocOverride()
+ win = WindowWithSizeAllocOverride()
rect = Gdk.Rectangle()
rect.width = 100
rect.height = 100
diff --git a/tests/test_properties.py b/tests/test_properties.py
index d7ceb89..c0579f7 100644
--- a/tests/test_properties.py
+++ b/tests/test_properties.py
@@ -21,10 +21,15 @@ from gi.repository.GObject import \
from gi.repository import Gio
from gi.repository import GLib
-from gi.repository import Regress
from gi.repository import GIMarshallingTests
from gi import _propertyhelper as propertyhelper
+try:
+ from gi.repository import Regress
+ has_regress = True
+except ImportError:
+ has_regress = False
+
if sys.version_info < (3, 0):
TEST_UTF8 = "\xe2\x99\xa5"
UNICODE_UTF8 = unicode(TEST_UTF8, 'UTF-8')
@@ -73,19 +78,20 @@ class PropertyObject(GObject.GObject):
type=Gio.File, flags=PARAM_READWRITE | PARAM_CONSTRUCT)
-class PropertyInheritanceObject(Regress.TestObj):
- # override property from the base class, with a different type
- string = GObject.Property(type=int)
-
- # a property entirely defined at the Python level
- python_prop = GObject.Property(type=str)
+if has_regress:
+ class PropertyInheritanceObject(Regress.TestObj):
+ # override property from the base class, with a different type
+ string = GObject.Property(type=int)
+ # a property entirely defined at the Python level
+ python_prop = GObject.Property(type=str)
-class PropertySubClassObject(PropertyInheritanceObject):
- # override property from the base class, with a different type
- python_prop = GObject.Property(type=int)
+ class PropertySubClassObject(PropertyInheritanceObject):
+ # override property from the base class, with a different type
+ python_prop = GObject.Property(type=int)
+@unittest.skipUnless(has_regress, 'Missing Regress typelib')
class TestPropertyInheritanceObject(unittest.TestCase):
def test_override_gi_property(self):
self.assertNotEqual(Regress.TestObj.props.string.value_type,
@@ -728,6 +734,7 @@ class TestProperty(unittest.TestCase):
b.prop1 = 20
self.assertEqual(b.prop1, 20)
+ @unittest.skipUnless(has_regress, 'Missing regress typelib')
def test_property_subclass_c(self):
class A(Regress.TestSubObj):
prop1 = GObject.Property(type=int)