[Tests] Ensure GTKUI tests are skipped upon import errors

Need to catch any issues with importing GTK modules to ensure
GTKUI tests are skipped in non-GTK environments.
This commit is contained in:
Calum Lind 2018-10-11 17:05:55 +01:00
parent 729f062ea1
commit 7c1c3f62d1
1 changed files with 7 additions and 6 deletions

View File

@ -22,18 +22,19 @@ from .basetest import BaseTestCase
# Allow running other tests without GTKUI dependencies available # Allow running other tests without GTKUI dependencies available
try: try:
from gi.repository.GObject import TYPE_UINT64
except ImportError:
libs_available = False
TYPE_UINT64 = 'Whatever'
else:
libs_available = True
# pylint: disable=ungrouped-imports # pylint: disable=ungrouped-imports
from gi.repository.GObject import TYPE_UINT64
from deluge.ui.gtk3.gtkui import DEFAULT_PREFS from deluge.ui.gtk3.gtkui import DEFAULT_PREFS
from deluge.ui.gtk3.mainwindow import MainWindow from deluge.ui.gtk3.mainwindow import MainWindow
from deluge.ui.gtk3.menubar import MenuBar from deluge.ui.gtk3.menubar import MenuBar
from deluge.ui.gtk3.torrentdetails import TorrentDetails from deluge.ui.gtk3.torrentdetails import TorrentDetails
from deluge.ui.gtk3.torrentview import TorrentView from deluge.ui.gtk3.torrentview import TorrentView
except (ImportError, ValueError):
libs_available = False
TYPE_UINT64 = 'Whatever'
else:
libs_available = True
setup_translations() setup_translations()