|
|
7bb518b |
From 5ba871c0851dbff28320ec5887960a90a7aab260 Mon Sep 17 00:00:00 2001
|
|
|
7bb518b |
From: Haikel Guemar <hguemar@fedoraproject.org>
|
|
|
7bb518b |
Date: Fri, 30 Nov 2018 14:30:08 +0100
|
|
|
7bb518b |
Subject: [PATCH] Migrate Gtk interface to GObject introspection
|
|
|
7bb518b |
|
|
|
7bb518b |
Filters subunit2gtk and subunit-notify now uses GObject introspection
|
|
|
7bb518b |
Both are compatible with python2 and python3
|
|
|
7bb518b |
---
|
|
|
7bb518b |
filters/subunit-notify | 10 +++---
|
|
|
7bb518b |
filters/subunit2gtk | 80 +++++++++++++++++++++---------------------
|
|
|
7bb518b |
2 files changed, 45 insertions(+), 45 deletions(-)
|
|
|
7bb518b |
|
|
|
7bb518b |
diff --git a/filters/subunit-notify b/filters/subunit-notify
|
|
|
7bb518b |
index bc833da..71da071 100755
|
|
|
7bb518b |
--- a/filters/subunit-notify
|
|
|
7bb518b |
+++ b/filters/subunit-notify
|
|
|
7bb518b |
@@ -16,15 +16,15 @@
|
|
|
7bb518b |
|
|
|
7bb518b |
"""Notify the user of a finished test run."""
|
|
|
7bb518b |
|
|
|
7bb518b |
-import pygtk
|
|
|
7bb518b |
-pygtk.require('2.0')
|
|
|
7bb518b |
-import pynotify
|
|
|
7bb518b |
+import gi
|
|
|
7bb518b |
+gi.require_version('Gtk', '3.0')
|
|
|
7bb518b |
+from gi.repository import Notify
|
|
|
7bb518b |
from testtools import StreamToExtendedDecorator
|
|
|
7bb518b |
|
|
|
7bb518b |
from subunit import TestResultStats
|
|
|
7bb518b |
from subunit.filters import run_filter_script
|
|
|
7bb518b |
|
|
|
7bb518b |
-if not pynotify.init("Subunit-notify"):
|
|
|
7bb518b |
+if not Notify.init("Subunit-notify"):
|
|
|
7bb518b |
sys.exit(1)
|
|
|
7bb518b |
|
|
|
7bb518b |
|
|
|
7bb518b |
@@ -39,7 +39,7 @@ def notify_of_result(result):
|
|
|
7bb518b |
result.passed_tests,
|
|
|
7bb518b |
result.failed_tests,
|
|
|
7bb518b |
)
|
|
|
7bb518b |
- nw = pynotify.Notification(summary, body)
|
|
|
7bb518b |
+ nw = Notify.Notification(summary, body)
|
|
|
7bb518b |
nw.show()
|
|
|
7bb518b |
|
|
|
7bb518b |
|
|
|
7bb518b |
diff --git a/filters/subunit2gtk b/filters/subunit2gtk
|
|
|
7bb518b |
index 78b4309..5c0ebe3 100755
|
|
|
7bb518b |
--- a/filters/subunit2gtk
|
|
|
7bb518b |
+++ b/filters/subunit2gtk
|
|
|
7bb518b |
@@ -49,9 +49,9 @@ import sys
|
|
|
7bb518b |
import threading
|
|
|
7bb518b |
import unittest
|
|
|
7bb518b |
|
|
|
7bb518b |
-import pygtk
|
|
|
7bb518b |
-pygtk.require('2.0')
|
|
|
7bb518b |
-import gtk, gtk.gdk, gobject
|
|
|
7bb518b |
+import gi
|
|
|
7bb518b |
+gi.require_version('Gtk', '3.0')
|
|
|
7bb518b |
+from gi.repository import Gtk, GObject
|
|
|
7bb518b |
|
|
|
7bb518b |
from testtools import StreamToExtendedDecorator
|
|
|
7bb518b |
|
|
|
7bb518b |
@@ -75,64 +75,64 @@ class GTKTestResult(unittest.TestResult):
|
|
|
7bb518b |
self.not_ok_label = None
|
|
|
7bb518b |
self.total_tests = None
|
|
|
7bb518b |
|
|
|
7bb518b |
- self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
|
|
|
7bb518b |
+ self.window = Gtk.Window(Gtk.WindowType.TOPLEVEL)
|
|
|
7bb518b |
self.window.set_resizable(True)
|
|
|
7bb518b |
|
|
|
7bb518b |
- self.window.connect("destroy", gtk.main_quit)
|
|
|
7bb518b |
+ self.window.connect("destroy", Gtk.main_quit)
|
|
|
7bb518b |
self.window.set_title("Tests...")
|
|
|
7bb518b |
self.window.set_border_width(0)
|
|
|
7bb518b |
|
|
|
7bb518b |
- vbox = gtk.VBox(False, 5)
|
|
|
7bb518b |
+ vbox = Gtk.VBox(False, 5)
|
|
|
7bb518b |
vbox.set_border_width(10)
|
|
|
7bb518b |
self.window.add(vbox)
|
|
|
7bb518b |
vbox.show()
|
|
|
7bb518b |
|
|
|
7bb518b |
# Create a centering alignment object
|
|
|
7bb518b |
- align = gtk.Alignment(0.5, 0.5, 0, 0)
|
|
|
7bb518b |
+ align = Gtk.Alignment.new(0.5, 0.5, 0, 0)
|
|
|
7bb518b |
vbox.pack_start(align, False, False, 5)
|
|
|
7bb518b |
align.show()
|
|
|
7bb518b |
|
|
|
7bb518b |
# Create the ProgressBar
|
|
|
7bb518b |
- self.pbar = gtk.ProgressBar()
|
|
|
7bb518b |
+ self.pbar = Gtk.ProgressBar()
|
|
|
7bb518b |
align.add(self.pbar)
|
|
|
7bb518b |
self.pbar.set_text("Running")
|
|
|
7bb518b |
self.pbar.show()
|
|
|
7bb518b |
self.progress_model = ProgressModel()
|
|
|
7bb518b |
|
|
|
7bb518b |
- separator = gtk.HSeparator()
|
|
|
7bb518b |
+ separator = Gtk.HSeparator()
|
|
|
7bb518b |
vbox.pack_start(separator, False, False, 0)
|
|
|
7bb518b |
separator.show()
|
|
|
7bb518b |
|
|
|
7bb518b |
# rows, columns, homogeneous
|
|
|
7bb518b |
- table = gtk.Table(2, 3, False)
|
|
|
7bb518b |
+ table = Gtk.Table(2, 3, False)
|
|
|
7bb518b |
vbox.pack_start(table, False, True, 0)
|
|
|
7bb518b |
table.show()
|
|
|
7bb518b |
# Show summary details about the run. Could use an expander.
|
|
|
7bb518b |
- label = gtk.Label("Run:")
|
|
|
7bb518b |
- table.attach(label, 0, 1, 1, 2, gtk.EXPAND | gtk.FILL,
|
|
|
7bb518b |
- gtk.EXPAND | gtk.FILL, 5, 5)
|
|
|
7bb518b |
+ label = Gtk.Label(label="Run:")
|
|
|
7bb518b |
+ table.attach(label, 0, 1, 1, 2, Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL,
|
|
|
7bb518b |
+ Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, 5, 5)
|
|
|
7bb518b |
label.show()
|
|
|
7bb518b |
- self.run_label = gtk.Label("N/A")
|
|
|
7bb518b |
- table.attach(self.run_label, 1, 2, 1, 2, gtk.EXPAND | gtk.FILL,
|
|
|
7bb518b |
- gtk.EXPAND | gtk.FILL, 5, 5)
|
|
|
7bb518b |
+ self.run_label = Gtk.Label(label="N/A")
|
|
|
7bb518b |
+ table.attach(self.run_label, 1, 2, 1, 2, Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL,
|
|
|
7bb518b |
+ Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, 5, 5)
|
|
|
7bb518b |
self.run_label.show()
|
|
|
7bb518b |
|
|
|
7bb518b |
- label = gtk.Label("OK:")
|
|
|
7bb518b |
- table.attach(label, 0, 1, 2, 3, gtk.EXPAND | gtk.FILL,
|
|
|
7bb518b |
- gtk.EXPAND | gtk.FILL, 5, 5)
|
|
|
7bb518b |
+ label = Gtk.Label(label="OK:")
|
|
|
7bb518b |
+ table.attach(label, 0, 1, 2, 3, Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL,
|
|
|
7bb518b |
+ Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, 5, 5)
|
|
|
7bb518b |
label.show()
|
|
|
7bb518b |
- self.ok_label = gtk.Label("N/A")
|
|
|
7bb518b |
- table.attach(self.ok_label, 1, 2, 2, 3, gtk.EXPAND | gtk.FILL,
|
|
|
7bb518b |
- gtk.EXPAND | gtk.FILL, 5, 5)
|
|
|
7bb518b |
+ self.ok_label = Gtk.Label(label="N/A")
|
|
|
7bb518b |
+ table.attach(self.ok_label, 1, 2, 2, 3, Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL,
|
|
|
7bb518b |
+ Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, 5, 5)
|
|
|
7bb518b |
self.ok_label.show()
|
|
|
7bb518b |
|
|
|
7bb518b |
- label = gtk.Label("Not OK:")
|
|
|
7bb518b |
- table.attach(label, 0, 1, 3, 4, gtk.EXPAND | gtk.FILL,
|
|
|
7bb518b |
- gtk.EXPAND | gtk.FILL, 5, 5)
|
|
|
7bb518b |
+ label = Gtk.Label(label="Not OK:")
|
|
|
7bb518b |
+ table.attach(label, 0, 1, 3, 4, Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL,
|
|
|
7bb518b |
+ Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, 5, 5)
|
|
|
7bb518b |
label.show()
|
|
|
7bb518b |
- self.not_ok_label = gtk.Label("N/A")
|
|
|
7bb518b |
- table.attach(self.not_ok_label, 1, 2, 3, 4, gtk.EXPAND | gtk.FILL,
|
|
|
7bb518b |
- gtk.EXPAND | gtk.FILL, 5, 5)
|
|
|
7bb518b |
+ self.not_ok_label = Gtk.Label(label="N/A")
|
|
|
7bb518b |
+ table.attach(self.not_ok_label, 1, 2, 3, 4, Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL,
|
|
|
7bb518b |
+ Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, 5, 5)
|
|
|
7bb518b |
self.not_ok_label.show()
|
|
|
7bb518b |
|
|
|
7bb518b |
self.window.show()
|
|
|
7bb518b |
@@ -142,7 +142,7 @@ class GTKTestResult(unittest.TestResult):
|
|
|
7bb518b |
|
|
|
7bb518b |
def stopTest(self, test):
|
|
|
7bb518b |
super(GTKTestResult, self).stopTest(test)
|
|
|
7bb518b |
- gobject.idle_add(self._stopTest)
|
|
|
7bb518b |
+ GObject.idle_add(self._stopTest)
|
|
|
7bb518b |
|
|
|
7bb518b |
def _stopTest(self):
|
|
|
7bb518b |
self.progress_model.advance()
|
|
|
7bb518b |
@@ -159,26 +159,26 @@ class GTKTestResult(unittest.TestResult):
|
|
|
7bb518b |
super(GTKTestResult, self).stopTestRun()
|
|
|
7bb518b |
except AttributeError:
|
|
|
7bb518b |
pass
|
|
|
7bb518b |
- gobject.idle_add(self.pbar.set_text, 'Finished')
|
|
|
7bb518b |
+ GObject.idle_add(self.pbar.set_text, 'Finished')
|
|
|
7bb518b |
|
|
|
7bb518b |
def addError(self, test, err):
|
|
|
7bb518b |
super(GTKTestResult, self).addError(test, err)
|
|
|
7bb518b |
- gobject.idle_add(self.update_counts)
|
|
|
7bb518b |
+ GObject.idle_add(self.update_counts)
|
|
|
7bb518b |
|
|
|
7bb518b |
def addFailure(self, test, err):
|
|
|
7bb518b |
super(GTKTestResult, self).addFailure(test, err)
|
|
|
7bb518b |
- gobject.idle_add(self.update_counts)
|
|
|
7bb518b |
+ GObject.idle_add(self.update_counts)
|
|
|
7bb518b |
|
|
|
7bb518b |
def addSuccess(self, test):
|
|
|
7bb518b |
super(GTKTestResult, self).addSuccess(test)
|
|
|
7bb518b |
- gobject.idle_add(self.update_counts)
|
|
|
7bb518b |
+ GObject.idle_add(self.update_counts)
|
|
|
7bb518b |
|
|
|
7bb518b |
def addSkip(self, test, reason):
|
|
|
7bb518b |
# addSkip is new in Python 2.7/3.1
|
|
|
7bb518b |
addSkip = getattr(super(GTKTestResult, self), 'addSkip', None)
|
|
|
7bb518b |
if callable(addSkip):
|
|
|
7bb518b |
addSkip(test, reason)
|
|
|
7bb518b |
- gobject.idle_add(self.update_counts)
|
|
|
7bb518b |
+ GObject.idle_add(self.update_counts)
|
|
|
7bb518b |
|
|
|
7bb518b |
def addExpectedFailure(self, test, err):
|
|
|
7bb518b |
# addExpectedFailure is new in Python 2.7/3.1
|
|
|
7bb518b |
@@ -186,7 +186,7 @@ class GTKTestResult(unittest.TestResult):
|
|
|
7bb518b |
'addExpectedFailure', None)
|
|
|
7bb518b |
if callable(addExpectedFailure):
|
|
|
7bb518b |
addExpectedFailure(test, err)
|
|
|
7bb518b |
- gobject.idle_add(self.update_counts)
|
|
|
7bb518b |
+ GObject.idle_add(self.update_counts)
|
|
|
7bb518b |
|
|
|
7bb518b |
def addUnexpectedSuccess(self, test):
|
|
|
7bb518b |
# addUnexpectedSuccess is new in Python 2.7/3.1
|
|
|
7bb518b |
@@ -194,7 +194,7 @@ class GTKTestResult(unittest.TestResult):
|
|
|
7bb518b |
'addUnexpectedSuccess', None)
|
|
|
7bb518b |
if callable(addUnexpectedSuccess):
|
|
|
7bb518b |
addUnexpectedSuccess(test)
|
|
|
7bb518b |
- gobject.idle_add(self.update_counts)
|
|
|
7bb518b |
+ GObject.idle_add(self.update_counts)
|
|
|
7bb518b |
|
|
|
7bb518b |
def progress(self, offset, whence):
|
|
|
7bb518b |
if whence == PROGRESS_PUSH:
|
|
|
7bb518b |
@@ -218,12 +218,12 @@ class GTKTestResult(unittest.TestResult):
|
|
|
7bb518b |
self.ok_label.set_text(str(self.testsRun - bad))
|
|
|
7bb518b |
self.not_ok_label.set_text(str(bad))
|
|
|
7bb518b |
|
|
|
7bb518b |
-gobject.threads_init()
|
|
|
7bb518b |
+GObject.threads_init()
|
|
|
7bb518b |
result = StreamToExtendedDecorator(GTKTestResult())
|
|
|
7bb518b |
test = ByteStreamToStreamResult(sys.stdin, non_subunit_name='stdout')
|
|
|
7bb518b |
# Get setup
|
|
|
7bb518b |
-while gtk.events_pending():
|
|
|
7bb518b |
- gtk.main_iteration()
|
|
|
7bb518b |
+while Gtk.events_pending():
|
|
|
7bb518b |
+ Gtk.main_iteration()
|
|
|
7bb518b |
# Start IO
|
|
|
7bb518b |
def run_and_finish():
|
|
|
7bb518b |
test.run(result)
|
|
|
7bb518b |
@@ -232,7 +232,7 @@ t = threading.Thread(target=run_and_finish)
|
|
|
7bb518b |
t.daemon = True
|
|
|
7bb518b |
result.startTestRun()
|
|
|
7bb518b |
t.start()
|
|
|
7bb518b |
-gtk.main()
|
|
|
7bb518b |
+Gtk.main()
|
|
|
7bb518b |
if result.decorated.wasSuccessful():
|
|
|
7bb518b |
exit_code = 0
|
|
|
7bb518b |
else:
|
|
|
7bb518b |
--
|
|
|
7bb518b |
2.19.2
|
|
|
7bb518b |
|