summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJean Felder <jfelder@src.gnome.org>2020-03-16 20:46:17 +0100
committerJean Felder <jfelder@src.gnome.org>2020-03-16 23:58:40 +0100
commitf3248b7bd5cf99950a60ecedb45d5ef85b9af4eb (patch)
tree46e5dcc438852e44c06d550461a099848636b720 /tests
parent2a1c627ae780aea2df7aa43fb6b2d69f2acda13d (diff)
downloadpygobject-f3248b7bd5cf99950a60ecedb45d5ef85b9af4eb.tar.gz
gtk overrides: Drop Gtk.main for Gtk4
It has been removed (gtk commit 4dd780a96b1d37903ab88a4ae4536329cd9e164e) The associated tests are updated or skipped for Gtk 4.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_ossig.py3
-rw-r--r--tests/test_overrides_gtk.py29
2 files changed, 26 insertions, 6 deletions
diff --git a/tests/test_ossig.py b/tests/test_ossig.py
index b59f2f5a..9340c02b 100644
--- a/tests/test_ossig.py
+++ b/tests/test_ossig.py
@@ -24,8 +24,10 @@ from contextlib import contextmanager
try:
from gi.repository import Gtk
+ Gtk_version = Gtk._version
except ImportError:
Gtk = None
+ Gtk_version = None
from gi.repository import Gio, GLib
from gi._ossighelper import wakeup_on_signal, register_sigint_fallback
@@ -90,6 +92,7 @@ class TestOverridesWakeupOnAlarm(unittest.TestCase):
app.run()
@unittest.skipIf(Gtk is None or os.name == "nt", "not on Windows")
+ @unittest.skipIf(Gtk is None or Gtk_version == "4.0", "not in gtk4")
def test_gtk_main(self):
signal.signal(signal.SIGALRM, lambda *args: Gtk.main_quit())
GLib.idle_add(signal.setitimer, signal.ITIMER_REAL, 0.001)
diff --git a/tests/test_overrides_gtk.py b/tests/test_overrides_gtk.py
index 0b4eae60..d0c6442e 100644
--- a/tests/test_overrides_gtk.py
+++ b/tests/test_overrides_gtk.py
@@ -65,8 +65,14 @@ def realized(widget):
window.add(widget)
widget.realize()
- while Gtk.events_pending():
- Gtk.main_iteration()
+ if Gtk._version == "4.0":
+ context = GLib.MainContext()
+ while context.pending():
+ context.iteration(False)
+ else:
+ while Gtk.events_pending():
+ Gtk.main_iteration()
+
assert widget.get_realized()
yield widget
@@ -74,8 +80,13 @@ def realized(widget):
window.remove(widget)
window.destroy()
- while Gtk.events_pending():
- Gtk.main_iteration()
+ if Gtk._version == "4.0":
+ context = GLib.MainContext()
+ while context.pending():
+ context.iteration(False)
+ else:
+ while Gtk.events_pending():
+ Gtk.main_iteration()
@unittest.skipUnless(Gtk, 'Gtk not available')
@@ -806,6 +817,7 @@ class TestGtk(unittest.TestCase):
self.assertEqual(stock_item.stock_id, 'gtk-ok')
self.assertEqual(Gtk.stock_lookup('nosuchthing'), None)
+ @unittest.skipIf(Gtk_version == "4.0", "not in gtk4")
def test_gtk_main(self):
# with no arguments
GLib.idle_add(Gtk.main_quit)
@@ -2396,8 +2408,13 @@ class TestTreeView(unittest.TestCase):
with realized(tree):
tree.set_cursor(model[0].path)
- while Gtk.events_pending():
- Gtk.main_iteration()
+ if Gtk._version == "4.0":
+ context = GLib.MainContext()
+ while context.pending():
+ context.iteration(False)
+ else:
+ while Gtk.events_pending():
+ Gtk.main_iteration()
self.assertEqual(tree.get_column(0).get_title(), 'Head1')
self.assertEqual(tree.get_column(1).get_title(), 'Head2')