[pygobject] tests: Move TestSignals from test_everything into test_signal



commit f127fabe9664b243774b76a68e6fce5986aa23a0
Author: Simon Feltman <sfeltman src gnome org>
Date:   Tue May 27 15:52:10 2014 -0700

    tests: Move TestSignals from test_everything into test_signal
    
    Move these tests into a more meaningful location.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=701843

 tests/test_everything.py |  123 -------------------------------------------
 tests/test_signal.py     |  131 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 131 insertions(+), 123 deletions(-)
---
diff --git a/tests/test_everything.py b/tests/test_everything.py
index f6017e4..094d8ad 100644
--- a/tests/test_everything.py
+++ b/tests/test_everything.py
@@ -1191,126 +1191,3 @@ class TestAdvancedInterfaces(unittest.TestCase):
 
         ret = obj.skip_return_val_no_out(1)
         self.assertEqual(ret, None)
-
-
- unittest skipUnless(has_cairo, 'built without cairo support')
-class TestSignals(unittest.TestCase):
-    def test_object_param_signal(self):
-        obj = Everything.TestObj()
-
-        def callback(obj, obj_param):
-            self.assertEqual(obj_param.props.int, 3)
-            self.assertGreater(obj_param.__grefcount__, 1)
-            obj.called = True
-
-        obj.called = False
-        obj.connect('sig-with-obj', callback)
-        obj.emit_sig_with_obj()
-        self.assertTrue(obj.called)
-
-    def test_connect_after(self):
-        obj = Everything.TestObj()
-
-        def callback(obj, obj_param):
-            obj.called = True
-
-        obj.called = False
-        obj.connect_after('sig-with-obj', callback)
-        obj.emit_sig_with_obj()
-        self.assertTrue(obj.called)
-
-    def test_connect_object(self):
-        obj = Everything.TestObj()
-
-        def callback(obj, obj_param):
-            obj.called = True
-
-        obj.called = False
-        obj.connect_object('sig-with-obj', callback, obj)
-        obj.emit_sig_with_obj()
-        self.assertTrue(obj.called)
-
-    def test_connect_object_after(self):
-        obj = Everything.TestObj()
-
-        def callback(obj, obj_param):
-            obj.called = True
-
-        obj.called = False
-        obj.connect_object_after('sig-with-obj', callback, obj)
-        obj.emit_sig_with_obj()
-        self.assertTrue(obj.called)
-
-    def test_int64_param_from_py(self):
-        obj = Everything.TestObj()
-
-        def callback(obj, i):
-            obj.callback_i = i
-            return i
-
-        obj.callback_i = None
-        obj.connect('sig-with-int64-prop', callback)
-        rv = obj.emit('sig-with-int64-prop', GObject.G_MAXINT64)
-        self.assertEqual(rv, GObject.G_MAXINT64)
-        self.assertEqual(obj.callback_i, GObject.G_MAXINT64)
-
-    def test_uint64_param_from_py(self):
-        obj = Everything.TestObj()
-
-        def callback(obj, i):
-            obj.callback_i = i
-            return i
-
-        obj.callback_i = None
-        obj.connect('sig-with-uint64-prop', callback)
-        rv = obj.emit('sig-with-uint64-prop', GObject.G_MAXUINT64)
-        self.assertEqual(rv, GObject.G_MAXUINT64)
-        self.assertEqual(obj.callback_i, GObject.G_MAXUINT64)
-
-    def test_int64_param_from_c(self):
-        obj = Everything.TestObj()
-
-        def callback(obj, i):
-            obj.callback_i = i
-            return i
-
-        obj.callback_i = None
-
-        obj.connect('sig-with-int64-prop', callback)
-        obj.emit_sig_with_int64()
-        self.assertEqual(obj.callback_i, GObject.G_MAXINT64)
-
-    def test_uint64_param_from_c(self):
-        obj = Everything.TestObj()
-
-        def callback(obj, i):
-            obj.callback_i = i
-            return i
-
-        obj.callback_i = None
-
-        obj.connect('sig-with-uint64-prop', callback)
-        obj.emit_sig_with_uint64()
-        self.assertEqual(obj.callback_i, GObject.G_MAXUINT64)
-
-    def test_intarray_ret(self):
-        obj = Everything.TestObj()
-
-        def callback(obj, i):
-            obj.callback_i = i
-            return [i, i + 1]
-
-        obj.callback_i = None
-
-        try:
-            obj.connect('sig-with-intarray-ret', callback)
-        except TypeError as e:
-            # compat with g-i 1.34.x
-            if 'unknown signal' in str(e):
-                return
-            raise
-
-        rv = obj.emit('sig-with-intarray-ret', 42)
-        self.assertEqual(obj.callback_i, 42)
-        self.assertEqual(type(rv), GLib.Array)
-        self.assertEqual(rv.len, 2)
diff --git a/tests/test_signal.py b/tests/test_signal.py
index 80d4ac5..20cb4ed 100644
--- a/tests/test_signal.py
+++ b/tests/test_signal.py
@@ -9,6 +9,14 @@ from gi import _signalhelper as signalhelper
 import testhelper
 from compathelper import _long
 
+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,
@@ -976,5 +984,128 @@ 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()
+
+        def callback(obj, obj_param):
+            self.assertEqual(obj_param.props.int, 3)
+            self.assertGreater(obj_param.__grefcount__, 1)
+            obj.called = True
+
+        obj.called = False
+        obj.connect('sig-with-obj', callback)
+        obj.emit_sig_with_obj()
+        self.assertTrue(obj.called)
+
+    def test_connect_after(self):
+        obj = Regress.TestObj()
+
+        def callback(obj, obj_param):
+            obj.called = True
+
+        obj.called = False
+        obj.connect_after('sig-with-obj', callback)
+        obj.emit_sig_with_obj()
+        self.assertTrue(obj.called)
+
+    def test_connect_object(self):
+        obj = Regress.TestObj()
+
+        def callback(obj, obj_param):
+            obj.called = True
+
+        obj.called = False
+        obj.connect_object('sig-with-obj', callback, obj)
+        obj.emit_sig_with_obj()
+        self.assertTrue(obj.called)
+
+    def test_connect_object_after(self):
+        obj = Regress.TestObj()
+
+        def callback(obj, obj_param):
+            obj.called = True
+
+        obj.called = False
+        obj.connect_object_after('sig-with-obj', callback, obj)
+        obj.emit_sig_with_obj()
+        self.assertTrue(obj.called)
+
+    def test_int64_param_from_py(self):
+        obj = Regress.TestObj()
+
+        def callback(obj, i):
+            obj.callback_i = i
+            return i
+
+        obj.callback_i = None
+        obj.connect('sig-with-int64-prop', callback)
+        rv = obj.emit('sig-with-int64-prop', GObject.G_MAXINT64)
+        self.assertEqual(rv, GObject.G_MAXINT64)
+        self.assertEqual(obj.callback_i, GObject.G_MAXINT64)
+
+    def test_uint64_param_from_py(self):
+        obj = Regress.TestObj()
+
+        def callback(obj, i):
+            obj.callback_i = i
+            return i
+
+        obj.callback_i = None
+        obj.connect('sig-with-uint64-prop', callback)
+        rv = obj.emit('sig-with-uint64-prop', GObject.G_MAXUINT64)
+        self.assertEqual(rv, GObject.G_MAXUINT64)
+        self.assertEqual(obj.callback_i, GObject.G_MAXUINT64)
+
+    def test_int64_param_from_c(self):
+        obj = Regress.TestObj()
+
+        def callback(obj, i):
+            obj.callback_i = i
+            return i
+
+        obj.callback_i = None
+
+        obj.connect('sig-with-int64-prop', callback)
+        obj.emit_sig_with_int64()
+        self.assertEqual(obj.callback_i, GObject.G_MAXINT64)
+
+    def test_uint64_param_from_c(self):
+        obj = Regress.TestObj()
+
+        def callback(obj, i):
+            obj.callback_i = i
+            return i
+
+        obj.callback_i = None
+
+        obj.connect('sig-with-uint64-prop', callback)
+        obj.emit_sig_with_uint64()
+        self.assertEqual(obj.callback_i, GObject.G_MAXUINT64)
+
+    def test_intarray_ret(self):
+        obj = Regress.TestObj()
+
+        def callback(obj, i):
+            obj.callback_i = i
+            return [i, i + 1]
+
+        obj.callback_i = None
+
+        try:
+            obj.connect('sig-with-intarray-ret', callback)
+        except TypeError as e:
+            # compat with g-i 1.34.x
+            if 'unknown signal' in str(e):
+                return
+            raise
+
+        rv = obj.emit('sig-with-intarray-ret', 42)
+        self.assertEqual(obj.callback_i, 42)
+        self.assertEqual(type(rv), GLib.Array)
+        self.assertEqual(rv.len, 2)
+
+
 if __name__ == '__main__':
     unittest.main()


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