Skip to content

Commit

Permalink
tests: check for Gtk initialization and don't run tests that depend o…
Browse files Browse the repository at this point in the history
…n it
  • Loading branch information
pfps committed Mar 25, 2024
1 parent 41aacef commit 04a818f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/solaar/ui/test_pair_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk # NOQA: E402

gtk_init = Gtk.init_check()[0]


@dataclass
class Device:
Expand Down Expand Up @@ -78,6 +80,7 @@ def destroy(self):
pass


@pytest.mark.skipif(not gtk_init, reason="requires Gtk")
@pytest.mark.parametrize(
"receiver, lock_open, discovering, page_type",
[
Expand Down Expand Up @@ -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",
[
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 04a818f

Please sign in to comment.