diff --git a/tests/integration/features/test_features.py b/tests/integration/features/test_features.py index 8a146895a..df93433d0 100644 --- a/tests/integration/features/test_features.py +++ b/tests/integration/features/test_features.py @@ -57,6 +57,12 @@ def reload(qtbot, httpbin, quteproc, command): quteproc.send_cmd(':reload') +@bdd.when("selection is supported") +def selection_supported(qapp): + if not qapp.clipboard().supportsSelection(): + pytest.skip("OS doesn't support primary selection!") + + @bdd.then(bdd.parsers.parse("{path} should be loaded")) def path_should_be_loaded(httpbin, path): requests = httpbin.get_requests() @@ -86,18 +92,14 @@ def expect_error(quteproc, httpbin, category, message): @bdd.then(bdd.parsers.re(r'the (?Pprimary selection|clipboard) should ' r'contain "(?P.*)"')) def clipboard_contains(qapp, httpbin, what, content): - clipboard = qapp.clipboard() - if what == 'clipboard': mode = QClipboard.Clipboard elif what == 'primary selection': - if not clipboard.supportsSelection(): - pytest.skip("OS doesn't support primary selection!") mode = QClipboard.Selection else: raise AssertionError expected = content.replace('(port)', str(httpbin.port)) - data = clipboard.text(mode=mode) + data = qapp.clipboard().text(mode=mode) assert data == expected diff --git a/tests/integration/features/yankpaste.feature b/tests/integration/features/yankpaste.feature index 195aa4f14..7c79612af 100644 --- a/tests/integration/features/yankpaste.feature +++ b/tests/integration/features/yankpaste.feature @@ -11,7 +11,8 @@ Feature: Yanking and pasting. And the clipboard should contain "http://localhost:(port)/data/yankpaste/test.html" Scenario: Yanking URLs to primary selection - When I run :yank --sel + When selection is supported + And I run :yank --sel Then the message "Yanked URL to primary selection: http://localhost:(port)/data/yankpaste/test.html" should be shown. And the primary selection should contain "http://localhost:(port)/data/yankpaste/test.html"