[pygobject] Wrap gio.Socket.condition_check() and add a test



commit 50960656815b0897a5ebe5f011537b8dcbdc857e
Author: Gian Mario Tagliaretti <gianmt gnome org>
Date:   Wed Dec 30 16:21:49 2009 +0100

    Wrap gio.Socket.condition_check() and add a test

 gio/Makefile.am       |    1 +
 gio/gio.override      |    1 +
 gio/gsocket.override  |   41 +++++++++++++++++++++++++++++++++++++++++
 tests/test_gsocket.py |   21 +++++++++++++++++++++
 4 files changed, 64 insertions(+), 0 deletions(-)
---
diff --git a/gio/Makefile.am b/gio/Makefile.am
index 51a8fbc..a734928 100644
--- a/gio/Makefile.am
+++ b/gio/Makefile.am
@@ -56,6 +56,7 @@ GIO_OVERRIDES = 			\
 	gmount.override			\
 	goutputstream.override 		\
 	gresolver.override		\
+	gsocket.override		\
 	gvolume.override		\
 	gvolumemonitor.override
 
diff --git a/gio/gio.override b/gio/gio.override
index 62833ee..d5ef514 100644
--- a/gio/gio.override
+++ b/gio/gio.override
@@ -248,6 +248,7 @@ include
   ginputstream.override
   goutputstream.override
   gresolver.override
+  gsocket.override
   gvolume.override
   gvolumemonitor.override
 %%
diff --git a/gio/gsocket.override b/gio/gsocket.override
new file mode 100644
index 0000000..2f009fc
--- /dev/null
+++ b/gio/gsocket.override
@@ -0,0 +1,41 @@
+/* -*- Mode: C; c-basic-offset: 4 -*-
+ * pygobject - Python bindings for GObject
+ * Copyright (C) 2009  Gian Mario Tagliaretti
+ *
+ *   gsocket.override: module overrides for GSocket and related types
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+
+%%
+override g_socket_condition_check kwargs
+static PyObject *
+_wrap_g_socket_condition_check(PyGObject *self,
+                               PyObject *args,
+                               PyObject *kwargs)
+{
+    static char *kwlist[] = { "condition", NULL };
+    gint condition, ret;
+
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+                                     "i:gio.Socket.condition_check",
+                                     kwlist, &condition))
+        return NULL;
+    
+    ret = g_socket_condition_check(G_SOCKET(self->obj), condition);
+    
+    return pyg_flags_from_gtype(G_TYPE_IO_CONDITION, ret);
+}
diff --git a/tests/test_gsocket.py b/tests/test_gsocket.py
new file mode 100644
index 0000000..8f138a4
--- /dev/null
+++ b/tests/test_gsocket.py
@@ -0,0 +1,21 @@
+# -*- Mode: Python -*-
+
+import os
+import unittest
+
+from common import gio, glib, gobject
+
+
+class TestSocket(unittest.TestCase):
+    def setUp(self):
+        self.sock = gio.Socket(gio.SOCKET_FAMILY_IPV4,
+                               gio.SOCKET_TYPE_STREAM,
+                               gio.SOCKET_PROTOCOL_TCP)
+
+    def test_socket_condition(self):
+        check = self.sock.condition_check(glib.IO_OUT)
+        self.failUnless(isinstance(check, gobject.GFlags))
+        self.failUnlessEqual(check, glib.IO_OUT | glib.IO_HUP)
+
+    def tearDown(self):
+        self.sock.close()



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