summaryrefslogtreecommitdiff
path: root/tests/test_gobject.py
diff options
context:
space:
mode:
authorChristoph Reiter <reiter.christoph@gmail.com>2018-04-24 13:34:31 +0200
committerChristoph Reiter <reiter.christoph@gmail.com>2018-04-24 14:22:20 +0200
commitcc3157c279dea92767a55ff61faaa8d450976c97 (patch)
tree2c2b6c63c9114e3b7154c2fdc16f99871bde9b86 /tests/test_gobject.py
parent19943e1dafbaffbbe368ba13029b784d916d998c (diff)
downloadpygobject-cc3157c279dea92767a55ff61faaa8d450976c97.tar.gz
Add tests for GObject.list_properties
Diffstat (limited to 'tests/test_gobject.py')
-rw-r--r--tests/test_gobject.py44
1 files changed, 43 insertions, 1 deletions
diff --git a/tests/test_gobject.py b/tests/test_gobject.py
index 36a6af18..cf3d8b54 100644
--- a/tests/test_gobject.py
+++ b/tests/test_gobject.py
@@ -7,7 +7,9 @@ import gc
import unittest
import warnings
-from gi.repository import GObject, GLib
+import pytest
+
+from gi.repository import GObject, GLib, Gio
from gi import PyGIDeprecationWarning
from gi.module import get_introspection_module
from gi import _gi
@@ -711,3 +713,43 @@ class TestGValue(unittest.TestCase):
value = GObject.Value(GLib.Error)
self.assertEqual(value.g_type, GObject.type_from_name('GError'))
self.assertEqual(value.get_value(), None)
+
+
+def test_list_properties():
+
+ def find_param(l, name):
+ for param in l:
+ if param.name == name:
+ return param
+ return
+
+ list_props = GObject.list_properties
+
+ props = list_props(Gio.Action)
+ param = find_param(props, "enabled")
+ assert param
+ assert param.value_type == GObject.TYPE_BOOLEAN
+ assert list_props("GAction") == list_props(Gio.Action)
+ assert list_props(Gio.Action.__gtype__) == list_props(Gio.Action)
+
+ props = list_props(Gio.SimpleAction)
+ assert find_param(props, "enabled")
+
+ def names(l):
+ return [p.name for p in l]
+
+ assert (set(names(list_props(Gio.Action))) <=
+ set(names(list_props(Gio.SimpleAction))))
+
+ props = list_props(Gio.FileIcon)
+ param = find_param(props, "file")
+ assert param
+ assert param.value_type == Gio.File.__gtype__
+
+ assert list_props("GFileIcon") == list_props(Gio.FileIcon)
+ assert list_props(Gio.FileIcon.__gtype__) == list_props(Gio.FileIcon)
+ assert list_props(Gio.FileIcon()) == list_props(Gio.FileIcon)
+
+ for obj in [Gio.ActionEntry, Gio.DBusError, 0, object()]:
+ with pytest.raises(TypeError):
+ list_props(obj)