From 04a818f21516346757b87ea5856c6d6bbd0bd596 Mon Sep 17 00:00:00 2001 From: "Peter F. Patel-Schneider" Date: Tue, 19 Mar 2024 09:31:23 -0400 Subject: [PATCH] tests: check for Gtk initialization and don't run tests that depend on it --- tests/solaar/ui/test_pair_window.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/solaar/ui/test_pair_window.py b/tests/solaar/ui/test_pair_window.py index 9e25aeb0..1593f5c5 100644 --- a/tests/solaar/ui/test_pair_window.py +++ b/tests/solaar/ui/test_pair_window.py @@ -13,6 +13,8 @@ from solaar.ui import pair_window gi.require_version("Gtk", "3.0") from gi.repository import Gtk # NOQA: E402 +gtk_init = Gtk.init_check()[0] + @dataclass class Device: @@ -78,6 +80,7 @@ class Assistant: pass +@pytest.mark.skipif(not gtk_init, reason="requires Gtk") @pytest.mark.parametrize( "receiver, lock_open, discovering, page_type", [ @@ -124,6 +127,7 @@ def test_check_lock_state_drawable(assistant, expected_result): assert result == expected_result +@pytest.mark.skipif(not gtk_init, reason="requires Gtk") @pytest.mark.parametrize( "receiver, count, expected_result", [ @@ -197,6 +201,7 @@ def test_finish(receiver, pair_device, set_lock, discover, error, mocker): assert receiver.pairing.error == error +@pytest.mark.skipif(not gtk_init, reason="requires Gtk") @pytest.mark.parametrize("error", ["timeout", "device not supported", "too many devices"]) def test_create_failure_page(error, mocker): spy_create = mocker.spy(pair_window, "_create_page")