summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCalum Lind <calumlind+deluge@gmail.com>2021-09-26 15:33:53 +0100
committerCalum Lind <calumlind+deluge@gmail.com>2021-10-03 14:22:11 +0100
commit88fc21e9938e08827751509d4da20b9dad44bf92 (patch)
tree587b0e3c3a476e6dff111a769047c809f05cbc74
parent54674576dba2c5efd945c1e8f5accd2d8ca2afcd (diff)
downloaddeluge-88fc21e9938e08827751509d4da20b9dad44bf92.tar.gz
deluge-88fc21e9938e08827751509d4da20b9dad44bf92.tar.bz2
deluge-88fc21e9938e08827751509d4da20b9dad44bf92.zip
[Stats] Fix cairo error and failing tests
Fixed the Stats GTKUI test not updated to the new GTK3 dir layout. Fixed pygobject cairo ImageSurface error: AttributeError: 'gi.repository.cairo' object has no attribute 'ImageSurface' The documentation seems to suggest that using `import cairo` is the correct usage and this fixed the issue, along with adding suggested gi.require_foreign call. References: https://pygobject.readthedocs.io/en/latest/guide/cairo_integration.html
-rw-r--r--deluge/plugins/Stats/deluge_stats/graph.py6
-rw-r--r--deluge/plugins/Stats/deluge_stats/tests/test_stats.py16
2 files changed, 13 insertions, 9 deletions
diff --git a/deluge/plugins/Stats/deluge_stats/graph.py b/deluge/plugins/Stats/deluge_stats/graph.py
index 847c253d1..bc18913b3 100644
--- a/deluge/plugins/Stats/deluge_stats/graph.py
+++ b/deluge/plugins/Stats/deluge_stats/graph.py
@@ -20,7 +20,11 @@ import logging
import math
import time
-from gi.repository import cairo
+import gi
+
+gi.require_foreign('cairo') # NOQA: E402
+
+import cairo # isort:skip (gi checks required before import).
log = logging.getLogger(__name__)
diff --git a/deluge/plugins/Stats/deluge_stats/tests/test_stats.py b/deluge/plugins/Stats/deluge_stats/tests/test_stats.py
index 07741cbf3..ab2456877 100644
--- a/deluge/plugins/Stats/deluge_stats/tests/test_stats.py
+++ b/deluge/plugins/Stats/deluge_stats/tests/test_stats.py
@@ -75,14 +75,14 @@ class StatsTestCase(BaseTestCase):
from deluge_stats import graph, gtkui
from deluge.configmanager import ConfigManager
- from deluge.ui.gtkui.gtkui import DEFAULT_PREFS
- from deluge.ui.gtkui.mainwindow import MainWindow
- from deluge.ui.gtkui.pluginmanager import PluginManager
- from deluge.ui.gtkui.preferences import Preferences
- from deluge.ui.gtkui.torrentdetails import TorrentDetails
- from deluge.ui.gtkui.torrentview import TorrentView
-
- ConfigManager('gtkui.conf', defaults=DEFAULT_PREFS)
+ from deluge.ui.gtk3.gtkui import DEFAULT_PREFS
+ from deluge.ui.gtk3.mainwindow import MainWindow
+ from deluge.ui.gtk3.pluginmanager import PluginManager
+ from deluge.ui.gtk3.preferences import Preferences
+ from deluge.ui.gtk3.torrentdetails import TorrentDetails
+ from deluge.ui.gtk3.torrentview import TorrentView
+
+ ConfigManager('gtk3ui.conf', defaults=DEFAULT_PREFS)
self.plugins = PluginManager()
MainWindow()