summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2021-09-07 15:34:44 +0200
committerBastien Nocera <hadess@hadess.net>2021-09-07 15:38:47 +0200
commit9349f90db02b68211e568c5e543b46c7d0d22795 (patch)
treed665e8968b1e2e685a2b08d4fac1d356580a79c2
parent5e949205984eb4e40c80b119ed80fd381431feb2 (diff)
downloadupower-wip/hadess/fix-ci.tar.gz
linux: Postpone importing libraries for testswip/hadess/fix-ci
They're not needed and might not be available when we're trying to list the included tests.
-rwxr-xr-xsrc/linux/integration-test.py35
1 files changed, 17 insertions, 18 deletions
diff --git a/src/linux/integration-test.py b/src/linux/integration-test.py
index 3748e2a..0f31ffb 100755
--- a/src/linux/integration-test.py
+++ b/src/linux/integration-test.py
@@ -27,29 +27,11 @@ import time
from packaging.version import parse as parse_version
try:
- import gi
- from gi.repository import GLib
- from gi.repository import Gio
- gi.require_version('UPowerGlib', '1.0')
- from gi.repository import UPowerGlib
-except ImportError as e:
- sys.stderr.write('Skipping tests, PyGobject not available for Python 3, or missing GI typelibs: %s\n' % str(e))
- sys.exit(77)
-
-try:
- gi.require_version('UMockdev', '1.0')
- from gi.repository import UMockdev
-except ImportError:
- sys.stderr.write('Skipping tests, umockdev not available (https://github.com/martinpitt/umockdev)\n')
- sys.exit(77)
-
-try:
import dbusmock
except ImportError:
sys.stderr.write('Skipping tests, python-dbusmock not available (http://pypi.python.org/pypi/python-dbusmock).\n')
sys.exit(77)
-
UP = 'org.freedesktop.UPower'
UP_DEVICE = 'org.freedesktop.UPower.Device'
UP_DISPLAY_OBJECT_PATH = '/org/freedesktop/UPower/devices/DisplayDevice'
@@ -1947,6 +1929,23 @@ class Tests(dbusmock.DBusTestCase):
return prop_str
if __name__ == '__main__':
+ try:
+ import gi
+ from gi.repository import GLib
+ from gi.repository import Gio
+ gi.require_version('UPowerGlib', '1.0')
+ from gi.repository import UPowerGlib
+ except ImportError as e:
+ sys.stderr.write('Skipping tests, PyGobject not available for Python 3, or missing GI typelibs: %s\n' % str(e))
+ sys.exit(77)
+
+ try:
+ gi.require_version('UMockdev', '1.0')
+ from gi.repository import UMockdev
+ except ImportError:
+ sys.stderr.write('Skipping tests, umockdev not available (https://github.com/martinpitt/umockdev)\n')
+ sys.exit(77)
+
# run ourselves under umockdev
if 'umockdev' not in os.environ.get('LD_PRELOAD', ''):
os.execvp('umockdev-wrapper', ['umockdev-wrapper'] + sys.argv)