[pygobject] tests: Fix tests under Wayland. Fixes #163



commit e427d1a3a44e882c998543bb2c189700409df873
Author: Christoph Reiter <reiter christoph gmail com>
Date:   Mon Feb 12 20:35:09 2018 +0100

    tests: Fix tests under Wayland. Fixes #163
    
    These tests try to test Gdk.Atom with the exsting API in libgdk
    but under Wayland they either don't return Gdk.Atom or block.
    
    Since they are disabled on other platforms just change them to only
    run under X11.

 tests/test_atoms.py | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
---
diff --git a/tests/test_atoms.py b/tests/test_atoms.py
index 0793d3ff..e1c5a897 100644
--- a/tests/test_atoms.py
+++ b/tests/test_atoms.py
@@ -1,7 +1,5 @@
 from __future__ import absolute_import
 
-import os
-import sys
 import unittest
 
 try:
@@ -14,6 +12,16 @@ except ImportError:
 from .helper import capture_glib_deprecation_warnings
 
 
+def is_X11():
+    try:
+        from gi.repository import Gdk, GdkX11
+    except ImportError:
+        return False
+
+    display = Gdk.Display.get_default()
+    return isinstance(display, GdkX11.X11Display)
+
+
 @unittest.skipUnless(Gdk, 'Gdk not available')
 class TestGdkAtom(unittest.TestCase):
     def test_create(self):
@@ -58,7 +66,7 @@ class TestGdkAtom(unittest.TestCase):
         self.assertTrue(Gtk.targets_include_image([a_jpeg], False))
         self.assertTrue(Gtk.targets_include_image([a_jpeg, a_plain], False))
 
-    @unittest.skipIf(sys.platform == "darwin", "fails on OSX")
+    @unittest.skipUnless(is_X11(), "only on X11")
     def test_out_array(self):
         a_selection = Gdk.Atom.intern('my_clipboard', False)
         clipboard = Gtk.Clipboard.get(a_selection)
@@ -78,8 +86,7 @@ class TestGdkAtom(unittest.TestCase):
         self.assertFalse(None in names, names)
         self.assertTrue('TEXT' in names, names)
 
-    @unittest.skipIf(sys.platform == "darwin" or os.name == "nt",
-                     "fails on OSX/Windows")
+    @unittest.skipUnless(is_X11(), "only on X11")
     @unittest.skipIf(not Gdk or Gdk._version == "4.0", "not in gdk4")
     def test_out_glist(self):
         display = Gdk.Display.get_default()


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