From 5aa4d07816abf9d5f8ffdf1f881f523f0df02246 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Sun, 19 Nov 2023 18:21:29 +0000 Subject: [PATCH] [Stats] Fix creating test artifacts in tmp not pwd --- deluge/plugins/Stats/deluge_stats/gtkui.py | 4 +++- deluge/plugins/Stats/deluge_stats/tests/test_stats.py | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/deluge/plugins/Stats/deluge_stats/gtkui.py b/deluge/plugins/Stats/deluge_stats/gtkui.py index c088060dc..141d59a02 100644 --- a/deluge/plugins/Stats/deluge_stats/gtkui.py +++ b/deluge/plugins/Stats/deluge_stats/gtkui.py @@ -9,9 +9,11 @@ # This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with # the additional special exception to link portions of this program with the OpenSSL library. # See LICENSE for more details. -# import logging +import gi # isort:skip (Required before Gtk import). + +gi.require_version('Gtk', '3.0') from gi.repository import Gtk from gi.repository.Gdk import RGBA diff --git a/deluge/plugins/Stats/deluge_stats/tests/test_stats.py b/deluge/plugins/Stats/deluge_stats/tests/test_stats.py index 4aefc509d..d61cd4666 100644 --- a/deluge/plugins/Stats/deluge_stats/tests/test_stats.py +++ b/deluge/plugins/Stats/deluge_stats/tests/test_stats.py @@ -58,7 +58,7 @@ class TestStatsPlugin: @pytest.mark.gtkui @defer.inlineCallbacks - def test_write(self): + def test_write(self, tmp_path): """ writing to a file-like object; need this for webui. @@ -102,5 +102,5 @@ class TestStatsPlugin: file_like = FakeFile() surface.write_to_png(file_like) data = b''.join(file_like.data) - with open('file_like.png', 'wb') as _file: + with open(tmp_path / 'file_like.png', 'wb') as _file: _file.write(data)