[pygobject] tests: Conditionalize usage of regress typelib in test_properties



commit 038563ed620e0d966e385a1779455d9b0e148c41
Author: Simon Feltman <sfeltman src gnome org>
Date:   Mon Mar 3 04:39:35 2014 -0800

    tests: Conditionalize usage of regress typelib in test_properties
    
    Unconditional usage of regress breaks tests when PyGObject is built without
    cairo.

 tests/test_properties.py |   27 +++++++++++++++++----------
 1 files changed, 17 insertions(+), 10 deletions(-)
---
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)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]