[pygobject/pygobject-2-28] [gi] Port test_properties from static gio to GI Gio



commit 5c2786804d997df680131542b4afb31e2db3a2cb
Author: Martin Pitt <martin pitt ubuntu com>
Date:   Wed Jul 13 10:40:25 2011 +0200

    [gi] Port test_properties from static gio to GI Gio
    
    As we ripped out the static gio bindings a while ago, this test case was using
    the system installed gio bindings with Python 2, and now fails completely with
    Python 3. Rewrite it to use gi.repository.Gio.

 tests/test_properties.py |   38 +++++++++++++++++++-------------------
 1 files changed, 19 insertions(+), 19 deletions(-)
---
diff --git a/tests/test_properties.py b/tests/test_properties.py
index 74c1b38..3930671 100644
--- a/tests/test_properties.py
+++ b/tests/test_properties.py
@@ -14,7 +14,7 @@ from gobject.constants import \
      G_MININT, G_MAXINT, G_MAXUINT, G_MINLONG, G_MAXLONG, \
      G_MAXULONG
 
-import gio
+from gi.repository import Gio
 
 if sys.version_info < (3, 0):
     TEST_UTF8 = "\xe2\x99\xa5"
@@ -37,7 +37,7 @@ class PropertyObject(GObject):
         type=TYPE_UINT64, flags=PARAM_READWRITE|PARAM_CONSTRUCT)
 
     enum = gobject.property(
-        type=gio.SocketType, default=gio.SOCKET_TYPE_STREAM)
+        type=Gio.SocketType, default=Gio.SocketType.STREAM)
 
 class TestProperties(unittest.TestCase):
     def testGetSet(self):
@@ -135,30 +135,30 @@ class TestProperties(unittest.TestCase):
 
     def testEnum(self):
         obj = new(PropertyObject)
-        self.assertEqual(obj.props.enum, gio.SOCKET_TYPE_STREAM)
-        self.assertEqual(obj.enum, gio.SOCKET_TYPE_STREAM)
-        obj.enum = gio.SOCKET_TYPE_DATAGRAM
-        self.assertEqual(obj.props.enum, gio.SOCKET_TYPE_DATAGRAM)
-        self.assertEqual(obj.enum, gio.SOCKET_TYPE_DATAGRAM)
-        obj.props.enum = gio.SOCKET_TYPE_STREAM
-        self.assertEqual(obj.props.enum, gio.SOCKET_TYPE_STREAM)
-        self.assertEqual(obj.enum, gio.SOCKET_TYPE_STREAM)
+        self.assertEqual(obj.props.enum, Gio.SocketType.STREAM)
+        self.assertEqual(obj.enum, Gio.SocketType.STREAM)
+        obj.enum = Gio.SocketType.DATAGRAM
+        self.assertEqual(obj.props.enum, Gio.SocketType.DATAGRAM)
+        self.assertEqual(obj.enum, Gio.SocketType.DATAGRAM)
+        obj.props.enum = Gio.SocketType.STREAM
+        self.assertEqual(obj.props.enum, Gio.SocketType.STREAM)
+        self.assertEqual(obj.enum, Gio.SocketType.STREAM)
         obj.props.enum = 2
-        self.assertEqual(obj.props.enum, gio.SOCKET_TYPE_DATAGRAM)
-        self.assertEqual(obj.enum, gio.SOCKET_TYPE_DATAGRAM)
+        self.assertEqual(obj.props.enum, Gio.SocketType.DATAGRAM)
+        self.assertEqual(obj.enum, Gio.SocketType.DATAGRAM)
         obj.enum = 1
-        self.assertEqual(obj.props.enum, gio.SOCKET_TYPE_STREAM)
-        self.assertEqual(obj.enum, gio.SOCKET_TYPE_STREAM)
+        self.assertEqual(obj.props.enum, Gio.SocketType.STREAM)
+        self.assertEqual(obj.enum, Gio.SocketType.STREAM)
 
         self.assertRaises(TypeError, setattr, obj, 'enum', 'foo')
         self.assertRaises(TypeError, setattr, obj, 'enum', object())
 
-        self.assertRaises(TypeError, gobject.property, type=gio.SocketType)
-        self.assertRaises(TypeError, gobject.property, type=gio.SocketType,
-                          default=gio.SOCKET_PROTOCOL_TCP)
-        self.assertRaises(TypeError, gobject.property, type=gio.SocketType,
+        self.assertRaises(TypeError, gobject.property, type=Gio.SocketType)
+        self.assertRaises(TypeError, gobject.property, type=Gio.SocketType,
+                          default=Gio.SocketProtocol.TCP)
+        self.assertRaises(TypeError, gobject.property, type=Gio.SocketType,
                           default=object())
-        self.assertRaises(TypeError, gobject.property, type=gio.SocketType,
+        self.assertRaises(TypeError, gobject.property, type=Gio.SocketType,
                           default=1)
 
     def testRange(self):



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