[pygobject/wip/jfelder/template-gtk4: 7/8] tests: Do not use container api when gtk4 is used
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject/wip/jfelder/template-gtk4: 7/8] tests: Do not use container api when gtk4 is used
- Date: Sun, 6 Dec 2020 14:06:21 +0000 (UTC)
commit 10932d80c4247a2e41e2e53ecbbc7aeaa0ab53e0
Author: Jean Felder <jfelder src gnome org>
Date: Sat Nov 21 15:50:42 2020 +0100
tests: Do not use container api when gtk4 is used
GTK4 removed the Gtk.Container interface. All GTK4 widgets are now
iterable.
tests/test_gtk_template.py | 41 +++++++++++++++++++++++++++++++++++------
1 file changed, 35 insertions(+), 6 deletions(-)
---
diff --git a/tests/test_gtk_template.py b/tests/test_gtk_template.py
index 9699cc7e..7243fd48 100644
--- a/tests/test_gtk_template.py
+++ b/tests/test_gtk_template.py
@@ -9,6 +9,7 @@ Gio = pytest.importorskip("gi.repository.Gio")
from .helper import capture_exceptions
+GTK4 = (Gtk._version == "4.0")
# https://gitlab.gnome.org/GNOME/pygobject/-/merge_requests/145
pytestmark = pytest.mark.skipif(Gtk._version == "4.0", reason="FIXME!!")
@@ -581,12 +582,26 @@ def test_internal_child():
__gtype_name__ = other_type_name
other = OtherThing()
- child = other.get_children()[0]
+ if not GTK4:
+ child = other.get_children()[0]
+ else:
+ child = other.get_first_child()
+
assert isinstance(child, MainThing)
- child = child.get_children()[0]
+
+ if not GTK4:
+ child = child.get_children()[0]
+ else:
+ child = child.get_first_child()
+
assert isinstance(child, Gtk.Box)
assert child.props.margin_top == 24
- child = child.get_children()[0]
+
+ if not GTK4:
+ child = child.get_children()[0]
+ else:
+ child = child.get_first_child()
+
assert isinstance(child, Gtk.Label)
assert child.props.label == "foo"
@@ -658,7 +673,12 @@ def test_template_hierarchy():
assert isinstance(self._testbox, TestBox)
assert isinstance(self._testlabel, TestLabel)
- assert len(self._testbox.get_children()) == 2
+ if not GTK4:
+ children = self._testbox.get_children()
+ else:
+ children = list(self._testbox)
+
+ assert len(children) == 2
win = MyWindow()
assert isinstance(win, MyWindow)
@@ -688,8 +708,17 @@ def test_multiple_init_template_calls():
my_box = MyBox()
assert isinstance(my_box, MyBox)
- assert len(my_box.get_children()) == 1
+ if not GTK4:
+ children = my_box.get_children()
+ else:
+ children = list(my_box)
+ assert len(children) == 1
my_box.init_template()
assert isinstance(my_box, MyBox)
- assert len(my_box.get_children()) == 1
+ if not GTK4:
+ children = my_box.get_children()
+ else:
+ children = list(my_box)
+
+ assert len(children) == 1
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]