diff --git a/doc/todo.txt b/doc/todo.txt index 3f85e234..713ee171 100644 --- a/doc/todo.txt +++ b/doc/todo.txt @@ -1,2 +1 @@ -- Only run GUI tests when X server is available (ie. DISPLAY is set) - Port to Python 3.x (will not happen anytime soon though) diff --git a/tests/__init__.py b/tests/__init__.py index 195d5865..8a8f4e65 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -183,6 +183,14 @@ def has_pyqt (): need_pyqt = _need_func(has_pyqt, "PyQT") +@memoized +def has_x11 (): + """Test if DISPLAY variable is set.""" + return os.getenv('DISPLAY') is not None + +need_x11 = _need_func(has_x11, 'X11') + + @contextmanager def _limit_time (seconds): """Raises LinkCheckerInterrupt if given number of seconds have passed.""" diff --git a/tests/test_gui.py b/tests/test_gui.py index 7c9af0de..0c3ac8f4 100644 --- a/tests/test_gui.py +++ b/tests/test_gui.py @@ -16,13 +16,14 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. import unittest import sys -from tests import need_pyqt +from tests import need_pyqt, need_x11 class TestGui (unittest.TestCase): """Test OMT GUI client.""" @need_pyqt + @need_x11 def test_gui (self): from PyQt4 import QtCore, QtGui, QtTest from linkcheck.gui import LinkCheckerMain