From 5c9ba3412d265071e09a6c59e0211e801fa33d0e Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sun, 3 Feb 2019 17:16:28 +0200 Subject: [PATCH] tests: python3 compatible way of importing gobject for D-Bus testing Signed-off-by: Jouni Malinen --- tests/hwsim/test_dbus.py | 6 +++++- tests/hwsim/test_dbus_old.py | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/hwsim/test_dbus.py b/tests/hwsim/test_dbus.py index 338c1dd90..0e690fab3 100644 --- a/tests/hwsim/test_dbus.py +++ b/tests/hwsim/test_dbus.py @@ -9,9 +9,13 @@ import logging logger = logging.getLogger() import subprocess import time +import sys try: - import gobject + if sys.version_info[0] > 2: + from gi.repository import GObject as gobject + else: + import gobject import dbus dbus_imported = True except ImportError: diff --git a/tests/hwsim/test_dbus_old.py b/tests/hwsim/test_dbus_old.py index bb6043e7e..4e132a0d4 100644 --- a/tests/hwsim/test_dbus_old.py +++ b/tests/hwsim/test_dbus_old.py @@ -6,9 +6,13 @@ import logging logger = logging.getLogger() +import sys try: - import gobject + if sys.version_info[0] > 2: + from gi.repository import GObject as gobject + else: + import gobject import dbus dbus_imported = True except ImportError: