From 4854ca42fd6c01d8dbb677048faecb7957e5e8d4 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 28 Sep 2015 21:50:55 +0200 Subject: [PATCH] Fix tests without DISPLAY. --- tests/unit/browser/test_cookies.py | 4 ++-- tests/unit/config/test_configtypes_hypothesis.py | 7 +++++++ tests/unit/misc/test_ipc.py | 3 +++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/unit/browser/test_cookies.py b/tests/unit/browser/test_cookies.py index c637c057e..356608fe7 100644 --- a/tests/unit/browser/test_cookies.py +++ b/tests/unit/browser/test_cookies.py @@ -128,7 +128,7 @@ def test_purge_old_cookies(config_stub, fake_save_manager): assert raw_cookies == [COOKIE1, COOKIE2, SESSION_COOKIE] -def test_save(config_stub, fake_save_manager, monkeypatch): +def test_save(config_stub, fake_save_manager, monkeypatch, qapp): """Test that expired and session cookies are not saved.""" monkeypatch.setattr(lineparser, 'LineParser', LineparserSaveStub) @@ -156,7 +156,7 @@ def test_cookies_changed_emit(config_stub, fake_save_manager, def test_cookies_changed_not_emitted(config_stub, fake_save_manager, - monkeypatch): + monkeypatch, qapp): """Test that changed is not emitted when nothing changes.""" config_stub.data = CONFIG_COOKIES_ENABLED monkeypatch.setattr(lineparser, diff --git a/tests/unit/config/test_configtypes_hypothesis.py b/tests/unit/config/test_configtypes_hypothesis.py index c5c02b16b..ab8bd0266 100644 --- a/tests/unit/config/test_configtypes_hypothesis.py +++ b/tests/unit/config/test_configtypes_hypothesis.py @@ -18,6 +18,8 @@ """Hypothesis tests for qutebrowser.config.configtypes.""" +import os +import sys import inspect import functools @@ -44,6 +46,11 @@ def gen_classes(): @hypothesis.given(strategies.text()) @hypothesis.example('\x00') def test_configtypes_hypothesis(klass, s): + if (klass in [configtypes.File, configtypes.UserStyleSheet] and + sys.platform == 'linux' and + not os.environ.get('DISPLAY', '')): + pytest.skip("No DISPLAY available") + try: klass().validate(s) except configexc.ValidationError: diff --git a/tests/unit/misc/test_ipc.py b/tests/unit/misc/test_ipc.py index c2f9610b2..c1e1b0633 100644 --- a/tests/unit/misc/test_ipc.py +++ b/tests/unit/misc/test_ipc.py @@ -45,6 +45,9 @@ from helpers import stubs # pylint: disable=import-error Args = collections.namedtuple('Args', 'basedir') +pytestmark = pytest.mark.usefixtures('qapp') + + @pytest.yield_fixture() def short_tmpdir(): with tempfile.TemporaryDirectory() as tdir: