[pygobject] tests: Don't skip Regress tests when cairo is missing
- From: Christoph Reiter <creiter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] tests: Don't skip Regress tests when cairo is missing
- Date: Sun, 2 Apr 2017 13:55:47 +0000 (UTC)
commit 7c774ce5ce9ec5cda61e10a704b28f0b82df1b03
Author: Christoph Reiter <creiter src gnome org>
Date: Sun Apr 2 10:54:48 2017 +0200
tests: Don't skip Regress tests when cairo is missing
Since https://git.gnome.org/browse/pygobject/commit/?id=a731db5908b79b97277be4f5138b46010c2dd616
we build libregress even if cairo is missing.
Instead of skipping regress tests when cairo is missing only skip cairo relate
tests now.
tests/test_cairo.py | 3 +--
tests/test_docstring.py | 10 +++-------
tests/test_everything.py | 17 +----------------
tests/test_import_machinery.py | 7 +------
tests/test_properties.py | 32 +++++++++++---------------------
tests/test_repository.py | 10 ----------
tests/test_signal.py | 15 +--------------
7 files changed, 18 insertions(+), 76 deletions(-)
---
diff --git a/tests/test_cairo.py b/tests/test_cairo.py
index 02049c0..3edf5d5 100644
--- a/tests/test_cairo.py
+++ b/tests/test_cairo.py
@@ -9,7 +9,6 @@ import gi
try:
gi.require_foreign('cairo')
import cairo
- from gi.repository import Regress
has_cairo = True
except ImportError:
has_cairo = False
@@ -23,7 +22,7 @@ except:
Gtk = None
Gdk = None
-from gi.repository import GObject
+from gi.repository import GObject, Regress
@unittest.skipUnless(has_cairo, 'built without cairo support')
diff --git a/tests/test_docstring.py b/tests/test_docstring.py
index d520b04..29b7e5e 100644
--- a/tests/test_docstring.py
+++ b/tests/test_docstring.py
@@ -2,19 +2,16 @@ import unittest
import gi.docstring
+from gi.repository import Regress
from gi.repository import GIMarshallingTests
from gi.repository import Gio
from gi.repository import GObject
from gi.repository import GLib
try:
- import cairo
- cairo = cairo
- has_cairo = True
- from gi.repository import Regress
from gi.repository import Gtk
except ImportError:
- has_cairo = False
+ Gtk = None
class Test(unittest.TestCase):
@@ -80,7 +77,6 @@ class Test(unittest.TestCase):
self.assertTrue('new()' in doc)
self.assertTrue('BoxedStruct()' in doc)
- @unittest.skipUnless(has_cairo, 'built without cairo support')
def test_private_struct_constructors(self):
# Structs without a size or constructor should have no constructor docs.
doc = Regress.TestBoxedPrivate.__doc__
@@ -94,7 +90,7 @@ class Test(unittest.TestCase):
self.assertEqual(GIMarshallingTests.array_out_etc.__doc__,
'array_out_etc(first:int, last:int) -> ints:list, sum:int')
- @unittest.skipUnless(has_cairo, 'built without cairo support')
+ @unittest.skipUnless(Gtk, 'no Gtk')
def test_shared_array_length_with_prior_out_arg(self):
# Test the 'iter' out argument does not effect length argument skipping.
self.assertEqual(Gtk.ListStore.insert_with_valuesv.__doc__,
diff --git a/tests/test_everything.py b/tests/test_everything.py
index b6405c1..0378781 100644
--- a/tests/test_everything.py
+++ b/tests/test_everything.py
@@ -8,14 +8,7 @@ import ctypes
import warnings
import sys
-try:
- import cairo
- cairo # Pyflakes
- has_cairo = True
- from gi.repository import Regress as Everything
-except ImportError:
- has_cairo = False
-
+from gi.repository import Regress as Everything
from gi.repository import GObject
from gi.repository import GLib
from gi.repository import Gio
@@ -53,7 +46,6 @@ class RawGList(ctypes.Structure):
return ctypes.POINTER(cls).from_address(id(obj) + offset)
-@unittest.skipUnless(has_cairo, 'built without cairo support')
class TestInstanceTransfer(unittest.TestCase):
def test_main(self):
@@ -62,7 +54,6 @@ class TestInstanceTransfer(unittest.TestCase):
obj.instance_method_full()
-@unittest.skipUnless(has_cairo, 'built without cairo support')
class TestEverything(unittest.TestCase):
def test_bool(self):
@@ -578,7 +569,6 @@ class TestEverything(unittest.TestCase):
self.assertTrue('test_everything.py", line' in tb, tb)
-@unittest.skipUnless(has_cairo, 'built without cairo support')
class TestNullableArgs(unittest.TestCase):
def test_in_nullable_hash(self):
Everything.test_ghash_null_in(None)
@@ -616,7 +606,6 @@ class TestNullableArgs(unittest.TestCase):
self.assertEqual(None, Everything.TestObj.null_out())
-@unittest.skipUnless(has_cairo, 'built without cairo support')
class TestCallbacks(unittest.TestCase):
called = False
main_loop = GLib.MainLoop()
@@ -1025,7 +1014,6 @@ class TestCallbacks(unittest.TestCase):
self.assertEqual(mydict, {'foo': 1, 'bar': 2, 'new': 42})
-@unittest.skipUnless(has_cairo, 'built without cairo support')
class TestClosures(unittest.TestCase):
def test_no_arg(self):
def callback():
@@ -1086,7 +1074,6 @@ class TestClosures(unittest.TestCase):
self.assertTrue('return value' in str(exc[0].value), exc[0].value)
-@unittest.skipUnless(has_cairo, 'built without cairo support')
class TestBoxed(unittest.TestCase):
def test_boxed(self):
object_ = Everything.TestObj()
@@ -1137,7 +1124,6 @@ class TestBoxed(unittest.TestCase):
self.assertNotEqual(id(boxed), id(copy))
-@unittest.skipUnless(has_cairo, 'built without cairo support')
class TestTortureProfile(unittest.TestCase):
def test_torture_profile(self):
import time
@@ -1200,7 +1186,6 @@ class TestTortureProfile(unittest.TestCase):
print("\tTotal: %f sec" % total_time)
-@unittest.skipUnless(has_cairo, 'built without cairo support')
class TestAdvancedInterfaces(unittest.TestCase):
def test_array_objs(self):
obj1, obj2 = Everything.test_array_fixed_out_objects()
diff --git a/tests/test_import_machinery.py b/tests/test_import_machinery.py
index dac48af..044117d 100644
--- a/tests/test_import_machinery.py
+++ b/tests/test_import_machinery.py
@@ -8,11 +8,7 @@ import gi.overrides
import gi.module
import gi.importer
-try:
- from gi.repository import Regress
- Regress # pyflakes
-except ImportError:
- Regress = None
+from gi.repository import Regress
class TestOverrides(unittest.TestCase):
@@ -27,7 +23,6 @@ class TestOverrides(unittest.TestCase):
except TypeError as e:
self.assertTrue('Can not override a type MyClass' in str(e))
- @unittest.skipUnless(Regress, 'built without cairo support')
def test_separate_path(self):
# Regress override is in tests/gi/overrides, separate from gi/overrides
# https://bugzilla.gnome.org/show_bug.cgi?id=680913
diff --git a/tests/test_properties.py b/tests/test_properties.py
index 30586d1..08af7a4 100644
--- a/tests/test_properties.py
+++ b/tests/test_properties.py
@@ -28,12 +28,8 @@ gi.require_version('GIMarshallingTests', '1.0')
from gi.repository import GIMarshallingTests
from gi import _propertyhelper as propertyhelper
-try:
- gi.require_version('Regress', '1.0')
- from gi.repository import Regress
- has_regress = True
-except (ValueError, ImportError):
- has_regress = False
+gi.require_version('Regress', '1.0')
+from gi.repository import Regress
if sys.version_info < (3, 0):
TEST_UTF8 = "\xe2\x99\xa5"
@@ -95,20 +91,19 @@ class PropertyObject(GObject.GObject):
flags=ParamFlags.READABLE | ParamFlags.WRITABLE | ParamFlags.CONSTRUCT)
-if has_regress:
- class PropertyInheritanceObject(Regress.TestObj):
- # override property from the base class, with a different type
- string = GObject.Property(type=int)
+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)
+ # 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,
@@ -769,7 +764,6 @@ 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)
@@ -1184,7 +1178,6 @@ class CPropertiesTestBase(object):
self.assertRaises(TypeError, self.set_prop, self.obj, 'some-boxed-glist', 'foo')
self.assertRaises(TypeError, self.set_prop, self.obj, 'some-boxed-glist', ['a'])
- @unittest.skipUnless(has_regress, 'built without cairo support')
def test_annotated_glist(self):
obj = Regress.TestObj()
self.assertEqual(self.get_prop(obj, 'list'), [])
@@ -1225,7 +1218,6 @@ class CPropertiesTestBase(object):
self.assertEqual(42, self.get_prop(obj, 'some-int'))
self.assertEqual(54, self.get_prop(obj, 'some-uchar'))
- @unittest.skipUnless(has_regress, 'built without cairo support')
def test_gtype(self):
obj = Regress.TestObj()
self.assertEqual(self.get_prop(obj, 'gtype'), GObject.TYPE_INVALID)
@@ -1237,7 +1229,6 @@ class CPropertiesTestBase(object):
self.set_prop(obj, 'gtype', str)
self.assertEqual(self.get_prop(obj, 'gtype'), GObject.TYPE_STRING)
- @unittest.skipUnless(has_regress, 'built without cairo support')
def test_hash_table(self):
obj = Regress.TestObj()
self.assertEqual(self.get_prop(obj, 'hash-table'), None)
@@ -1247,7 +1238,6 @@ class CPropertiesTestBase(object):
self.assertEqual(list(self.get_prop(obj, 'hash-table').items())[0],
('mec', 56))
- @unittest.skipUnless(has_regress, 'built without cairo support')
def test_parent_class(self):
class A(Regress.TestObj):
prop1 = GObject.Property(type=int)
diff --git a/tests/test_repository.py b/tests/test_repository.py
index f59f86b..1cd440e 100644
--- a/tests/test_repository.py
+++ b/tests/test_repository.py
@@ -33,13 +33,6 @@ from gi.repository import GObject
from gi.repository import GIMarshallingTests
from gi.repository import GIRepository as IntrospectedRepository
-try:
- import cairo
- cairo
- has_cairo = True
-except ImportError:
- has_cairo = False
-
from helper import capture_glib_warnings
@@ -149,7 +142,6 @@ class Test(unittest.TestCase):
self.assertEqual(GIRepository.RegisteredTypeInfo.get_type_init(info),
'gi_marshalling_tests_object_get_type')
- @unittest.skipUnless(has_cairo, 'Regress needs cairo')
def test_fundamental_object_info(self):
repo.require('Regress')
info = repo.find_by_name('Regress', 'TestFundamentalObject')
@@ -253,7 +245,6 @@ class Test(unittest.TestCase):
self.assertEqual(func_info.get_return_type().get_tag(), GIRepository.TypeTag.VOID)
self.assertRaises(AttributeError, func_info.get_return_attribute, '_not_an_attr')
- @unittest.skipUnless(has_cairo, 'Regress needs cairo')
def test_signal_info(self):
repo.require('Regress')
info = repo.find_by_name('Regress', 'TestObj')
@@ -270,7 +261,6 @@ class Test(unittest.TestCase):
self.assertFalse(sig_info.true_stops_emit())
self.assertEqual(sig_info.get_flags(), sig_flags)
- @unittest.skipUnless(has_cairo, 'Regress needs cairo')
def test_notify_signal_info_with_obj(self):
repo.require('Regress')
info = repo.find_by_name('Regress', 'TestObj')
diff --git a/tests/test_signal.py b/tests/test_signal.py
index 91607f9..4e81c1e 100644
--- a/tests/test_signal.py
+++ b/tests/test_signal.py
@@ -5,20 +5,12 @@ import unittest
import sys
import weakref
-from gi.repository import GObject, GLib
+from gi.repository import GObject, GLib, Regress
from gi import _signalhelper as signalhelper
import testhelper
from compathelper import _long
from helper import capture_glib_warnings, capture_gi_deprecation_warnings
-try:
- import cairo
- cairo # PyFlakes
- from gi.repository import Regress
- has_cairo = True
-except ImportError:
- has_cairo = False
-
class C(GObject.GObject):
__gsignals__ = {'my_signal': (GObject.SignalFlags.RUN_FIRST, None,
@@ -949,7 +941,6 @@ class TestConnectDataNonIntrospected(unittest.TestCase, _ConnectDataTestBase):
flags=GObject.SignalFlags.RUN_LAST)
-@unittest.skipUnless(has_cairo, 'built without cairo support')
class TestConnectDataIntrospected(unittest.TestCase, _ConnectDataTestBase):
# This tests connect_data with introspected signals brought in from Regress.
Object = Regress.TestObj
@@ -1089,7 +1080,6 @@ class TestSignalModuleLevelFunctions(unittest.TestCase):
None)
-@unittest.skipUnless(has_cairo, 'built without cairo support')
class TestIntrospectedSignals(unittest.TestCase):
def test_object_param_signal(self):
obj = Regress.TestObj()
@@ -1315,7 +1305,6 @@ class TestConnectGObjectNonIntrospected(unittest.TestCase, _ConnectObjectTestBas
pass
-@unittest.skipUnless(has_cairo, 'built without cairo support')
class TestConnectGObjectIntrospected(unittest.TestCase, _ConnectObjectTestBase):
# This tests connect_object with introspected signals brought in from Regress.
Object = Regress.TestObj
@@ -1338,7 +1327,6 @@ class TestConnectPyObjectNonIntrospected(unittest.TestCase, _ConnectObjectTestBa
SwapObject = object
-@unittest.skipUnless(has_cairo, 'built without cairo support')
class TestConnectPyObjectIntrospected(unittest.TestCase, _ConnectObjectTestBase):
# This tests connect_object with introspected signals brought in from Regress.
Object = Regress.TestObj
@@ -1474,7 +1462,6 @@ class TestRefCountsNonIntrospected(unittest.TestCase, _RefCountTestBase):
flags=GObject.SignalFlags.RUN_LAST)
-@unittest.skipUnless(has_cairo, 'built without cairo support')
class TestRefCountsIntrospected(unittest.TestCase, _RefCountTestBase):
Object = Regress.TestObj
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]