[gnome-bluetooth/wip/hadess/split-tests: 1/3] tests: Only load GnomeBluetoothPriv when running tests




commit c3d49d2d4a24e9daf931370d24413f857985b087
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Jan 20 13:53:16 2022 +0100

    tests: Only load GnomeBluetoothPriv when running tests
    
    Not when loading the script

 tests/integration-test.py | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)
---
diff --git a/tests/integration-test.py b/tests/integration-test.py
index a79066ef..543f3876 100755
--- a/tests/integration-test.py
+++ b/tests/integration-test.py
@@ -35,18 +35,18 @@ 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('GIRepository', '2.0')
-    from gi.repository import GIRepository
-    builddir = os.getenv('top_builddir', '.')
-    GIRepository.Repository.prepend_library_path(builddir + '/lib/')
-    GIRepository.Repository.prepend_search_path(builddir + '/lib/')
+gi.require_version('GIRepository', '2.0')
+from gi.repository import GIRepository
+builddir = os.getenv('top_builddir', '.')
+GIRepository.Repository.prepend_library_path(builddir + '/lib/')
+GIRepository.Repository.prepend_search_path(builddir + '/lib/')
 
+GNOME_BLUETOOTH_PRIV_UNAVAILABLE = False
+try:
     gi.require_version('GnomeBluetoothPriv', '3.0')
     from gi.repository import GnomeBluetoothPriv
-except ImportError as e:
-    sys.stderr.write('Could not find GnomeBluetoothPriv gobject-introspection data in the build dir: %s\n' % 
str(e))
-    sys.exit(1)
+except (ImportError, ValueError) as e:
+    GNOME_BLUETOOTH_PRIV_UNAVAILABLE = True
 
 try:
     import dbusmock
@@ -58,6 +58,10 @@ except ImportError:
 class OopTests(dbusmock.DBusTestCase):
     @classmethod
     def setUp(self):
+        if GNOME_BLUETOOTH_PRIV_UNAVAILABLE:
+            sys.stderr.write('Could not find GnomeBluetoothPriv gobject-introspection data in the build dir: 
%s\n' % str(e))
+            sys.exit(1)
+
         self.client = GnomeBluetoothPriv.Client.new()
         # used in test_pairing
         self.paired = False


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]