diff --git a/tests/test_pygdk3.py b/tests/test_pygdk3.py
index <HASH>..<HASH> 100644
--- a/tests/test_pygdk3.py
+++ b/tests/test_pygdk3.py
@@ -1,14 +1,18 @@
+from pyscreenshot.util import use_x_display
+
 from ref import backend_to_check, check_import
 
 ok = False
 if check_import("gi"):
-    import gi
-    # Arch: AttributeError: module 'gi' has no attribute 'require_version'
-    try:
-        gi.require_version
-        ok = True
-    except AttributeError:
-        pass
+    if use_x_display():
+        import gi
+
+        # Arch: AttributeError: module 'gi' has no attribute 'require_version'
+        try:
+            gi.require_version
+            ok = True
+        except AttributeError:
+            pass
 if ok:
 
     def test_pygdk3():
test: check gdk3 import