Daniel Brötzmann pushed to branch gtk4 at gajim / gajim


Commits:
06e7adca by wurstsalat at 2024-11-02T19:27:17+01:00
refactor: Tests: Move gi.require_versions into importable package function

This makes the function available for tests

- - - - -


6 changed files:

- gajim/main.py
- test/__init__.py
- test/common/__init__.py
- test/database/__init__.py
- test/gtk/__init__.py
- test/gui/__init__.py


Changes:

=====================================
gajim/main.py
=====================================
@@ -33,6 +33,22 @@ def check_version(dep_name: str, current_ver: str, min_ver: 
str) -> None:
                  f'(found {current_ver}) to run. Quitting...')
 
 
+def gi_require_versions() -> None:
+    import gi
+    gi.require_versions(
+        {
+            'GLib': '2.0',
+            'Gio': '2.0',
+            'Gdk': '4.0',
+            'Gtk': '4.0',
+            'GtkSource': '5',
+            'GObject': '2.0',
+            'Pango': '1.0',
+            'PangoCairo': '1.0',
+        }
+    )
+
+
 def _check_required_deps() -> None:
     error_message = 'Gajim needs {0} to run. Quitting… (Error: {1})'
 
@@ -47,14 +63,7 @@ def _check_required_deps() -> None:
         sys.exit(error_message.format('pygobject', error))
 
     try:
-        gi.require_versions({'GLib': '2.0',
-                             'Gio': '2.0',
-                             'Gdk': '4.0',
-                             'Gtk': '4.0',
-                             'GtkSource': '5',
-                             'GObject': '2.0',
-                             'Pango': '1.0',
-                             'PangoCairo': '1.0'})
+        gi_require_versions()
     except ValueError as error:
         sys.exit(f'Missing dependency: {error}')
 


=====================================
test/__init__.py
=====================================
@@ -1,20 +1,3 @@
-import gi
+from gajim.main import gi_require_versions
 
-
-def require_versions():
-    gi.require_versions(
-        {
-            'Gdk': '4.0',
-            'Gio': '2.0',
-            'GLib': '2.0',
-            'GObject': '2.0',
-            'Gst': '1.0',
-            'Gtk': '4.0',
-            'GtkSource': '5',
-            'Pango': '1.0',
-            'PangoCairo': '1.0',
-        }
-    )
-
-
-require_versions()
+gi_require_versions()


=====================================
test/common/__init__.py
=====================================
@@ -2,6 +2,10 @@
 #
 # SPDX-License-Identifier: GPL-3.0-or-later
 
+from gajim.main import gi_require_versions
+
+gi_require_versions()
+
 from gajim.common import app
 from gajim.common.settings import Settings
 


=====================================
test/database/__init__.py
=====================================
@@ -2,6 +2,10 @@
 #
 # SPDX-License-Identifier: GPL-3.0-or-later
 
+from gajim.main import gi_require_versions
+
+gi_require_versions()
+
 from gajim.common import configpaths
 
 configpaths.init()


=====================================
test/gtk/__init__.py
=====================================
@@ -0,0 +1,7 @@
+# This file is part of Gajim.
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+from gajim.main import gi_require_versions
+
+gi_require_versions()


=====================================
test/gui/__init__.py
=====================================
@@ -0,0 +1,7 @@
+# This file is part of Gajim.
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+from gajim.main import gi_require_versions
+
+gi_require_versions()



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/06e7adca39f22e461b9cb111865609e8b07ac6d4

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/06e7adca39f22e461b9cb111865609e8b07ac6d4
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to