summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Reiter <reiter.christoph@gmail.com>2018-02-12 20:35:09 +0100
committerChristoph Reiter <reiter.christoph@gmail.com>2018-02-12 20:39:48 +0100
commite427d1a3a44e882c998543bb2c189700409df873 (patch)
tree93f56e8cf12db0733b25c338910b3dac5c82fd1e
parent3e91df3dca3691635b978d1dc661506213e0efe3 (diff)
downloadpygobject-e427d1a3a44e882c998543bb2c189700409df873.tar.gz
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.
-rw-r--r--tests/test_atoms.py17
1 files 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()