summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLembrun <amadeusk7@free.fr>2021-03-07 18:00:36 +0100
committerLembrun <amadeusk7@free.fr>2021-03-07 18:00:36 +0100
commitff83241c81a6574106c70642b7de4824ccc1e9be (patch)
tree22cf073a1a60d3d9f15c3a6c68203e43d1317867 /tests
parenta015e2603b91cdc796c3729e612112dacc0a62fc (diff)
parent423e7e25bdd7de78c7a75d70bfc92171fcf8ccaf (diff)
downloadqutebrowser-ff83241c81a6574106c70642b7de4824ccc1e9be.tar.gz
qutebrowser-ff83241c81a6574106c70642b7de4824ccc1e9be.zip
Merge branch 'master' into Add-utils/resources.py
Diffstat (limited to 'tests')
-rw-r--r--tests/end2end/features/editor.feature49
-rw-r--r--tests/end2end/features/sessions.feature5
-rw-r--r--tests/end2end/features/tabs.feature5
-rw-r--r--tests/end2end/features/test_editor_bdd.py37
-rw-r--r--tests/unit/completion/test_models.py11
-rw-r--r--tests/unit/misc/test_guiprocess.py2
6 files changed, 68 insertions, 41 deletions
diff --git a/tests/end2end/features/editor.feature b/tests/end2end/features/editor.feature
index 52756422c..47cb1230a 100644
--- a/tests/end2end/features/editor.feature
+++ b/tests/end2end/features/editor.feature
@@ -6,14 +6,14 @@ Feature: Opening external editors
Scenario: Editing a URL
When I open data/numbers/1.txt
- And I set up a fake editor replacing "1.txt" by "2.txt"
+ And I setup a fake editor replacing "1.txt" by "2.txt"
And I run :edit-url
Then data/numbers/2.txt should be loaded
Scenario: Editing a URL with -t
When I run :tab-only
And I open data/numbers/1.txt
- And I set up a fake editor replacing "1.txt" by "2.txt"
+ And I setup a fake editor replacing "1.txt" by "2.txt"
And I run :edit-url -t
Then data/numbers/2.txt should be loaded
And the following tabs should be open:
@@ -24,7 +24,7 @@ Feature: Opening external editors
When I set tabs.new_position.related to prev
And I open data/numbers/1.txt
And I run :tab-only
- And I set up a fake editor replacing "1.txt" by "2.txt"
+ And I setup a fake editor replacing "1.txt" by "2.txt"
And I run :edit-url -rt
Then data/numbers/2.txt should be loaded
And the following tabs should be open:
@@ -34,7 +34,7 @@ Feature: Opening external editors
Scenario: Editing a URL with -b
When I run :tab-only
And I open data/numbers/1.txt
- And I set up a fake editor replacing "1.txt" by "2.txt"
+ And I setup a fake editor replacing "1.txt" by "2.txt"
And I run :edit-url -b
Then data/numbers/2.txt should be loaded
And the following tabs should be open:
@@ -45,7 +45,7 @@ Feature: Opening external editors
When I run :window-only
And I open data/numbers/1.txt in a new tab
And I run :tab-only
- And I set up a fake editor replacing "1.txt" by "2.txt"
+ And I setup a fake editor replacing "1.txt" by "2.txt"
And I run :edit-url -w
Then data/numbers/2.txt should be loaded
And the session should look like:
@@ -65,7 +65,7 @@ Feature: Opening external editors
When I open data/numbers/1.txt in a new tab
And I run :tab-only
And I run :window-only
- And I set up a fake editor replacing "1.txt" by "2.txt"
+ And I setup a fake editor replacing "1.txt" by "2.txt"
And I run :edit-url -p
Then data/numbers/2.txt should be loaded
And the session should look like:
@@ -90,13 +90,13 @@ Feature: Opening external editors
Scenario: Editing a URL with invalid URL
When I set url.auto_search to never
And I open data/hello.txt
- And I set up a fake editor replacing "http://localhost:(port)/data/hello.txt" by "foo!"
+ And I setup a fake editor replacing "http://localhost:(port)/data/hello.txt" by "foo!"
And I run :edit-url
Then the error "Invalid URL" should be shown
Scenario: Spawning an editor successfully
Given I have a fresh instance
- When I set up a fake editor returning "foobar"
+ When I setup a fake editor returning "foobar"
And I open data/editor.html
And I run :click-element id qute-textarea
And I wait for "Entering mode KeyMode.insert (reason: clicking input)" in the log
@@ -105,7 +105,7 @@ Feature: Opening external editors
Then the javascript message "text: foobar" should be logged
Scenario: Spawning an editor in normal mode
- When I set up a fake editor returning "foobar"
+ When I setup a fake editor returning "foobar"
And I open data/editor.html
And I run :click-element id qute-textarea
And I wait for "Entering mode KeyMode.insert (reason: clicking input)" in the log
@@ -119,7 +119,7 @@ Feature: Opening external editors
# There's no guarantee that the tab gets deleted...
@posix
Scenario: Spawning an editor and closing the tab
- When I set up a fake editor that writes "foobar" on save
+ When I setup a fake editor that writes "foobar" on save
And I open data/editor.html
And I run :click-element id qute-textarea
And I wait for "Entering mode KeyMode.insert (reason: clicking input)" in the log
@@ -134,7 +134,7 @@ Feature: Opening external editors
# Could not get signals working on Windows
@posix
Scenario: Spawning an editor and saving
- When I set up a fake editor that writes "foobar" on save
+ When I setup a fake editor that writes "foobar" on save
And I open data/editor.html
And I run :click-element id qute-textarea
And I wait for "Entering mode KeyMode.insert (reason: clicking input)" in the log
@@ -145,7 +145,7 @@ Feature: Opening external editors
Then the javascript message "text: foobar" should be logged
Scenario: Spawning an editor in caret mode
- When I set up a fake editor returning "foobar"
+ When I setup a fake editor returning "foobar"
And I open data/editor.html
And I run :click-element id qute-textarea
And I wait for "Entering mode KeyMode.insert (reason: clicking input)" in the log
@@ -159,7 +159,7 @@ Feature: Opening external editors
Then the javascript message "text: foobar" should be logged
Scenario: Spawning an editor with existing text
- When I set up a fake editor replacing "foo" by "bar"
+ When I setup a fake editor replacing "foo" by "bar"
And I open data/editor.html
And I run :click-element id qute-textarea
And I wait for "Entering mode KeyMode.insert (reason: clicking input)" in the log
@@ -173,20 +173,20 @@ Feature: Opening external editors
Scenario: Edit a command and run it
When I run :set-cmd-text :message-info foo
- And I set up a fake editor replacing "foo" by "bar"
+ And I setup a fake editor replacing "foo" by "bar"
And I run :edit-command --run
Then the message "bar" should be shown
And "Leaving mode KeyMode.command (reason: cmd accept)" should be logged
Scenario: Edit a command and omit the start char
- When I set up a fake editor returning "message-info foo"
+ When I setup a fake editor returning "message-info foo"
And I run :edit-command
Then the error "command must start with one of :/?" should be shown
And "Leaving mode KeyMode.command *" should not be logged
Scenario: Edit a command to be empty
When I run :set-cmd-text :
- When I set up a fake editor returning empty text
+ When I setup a fake editor returning empty text
And I run :edit-command
Then the error "command must start with one of :/?" should be shown
And "Leaving mode KeyMode.command *" should not be logged
@@ -194,13 +194,20 @@ Feature: Opening external editors
## select single file
Scenario: Select one file with single command
- When I set up a fake "single_file" fileselector selecting "tests/end2end/data/numbers/1.txt"
+ When I setup a fake single_file fileselector selecting "tests/end2end/data/numbers/1.txt" and writes to a temporary file
+ And I open data/fileselect.html
+ And I run :click-element id single_file
+ Then the javascript message "Files: 1.txt" should be logged
+
+ Scenario: Select one file with single command that writes to stdout
+ When I setup a fake single_file fileselector selecting "tests/end2end/data/numbers/1.txt" and writes to stdout
And I open data/fileselect.html
And I run :click-element id single_file
Then the javascript message "Files: 1.txt" should be logged
Scenario: Select two files with single command
- When I set up a fake "single_file" fileselector selecting "tests/end2end/data/numbers/1.txt tests/end2end/data/numbers/2.txt"
+ When I setup a fake single_file fileselector selecting "tests/end2end/data/numbers/1.txt tests/end2end/data/numbers/2.txt" and writes to a temporary file
+
And I open data/fileselect.html
And I run :click-element id single_file
Then the javascript message "Files: 1.txt" should be logged
@@ -209,13 +216,15 @@ Feature: Opening external editors
## select multiple files
Scenario: Select one file with multiple command
- When I set up a fake "multiple_files" fileselector selecting "tests/end2end/data/numbers/1.txt"
+ When I setup a fake multiple_files fileselector selecting "tests/end2end/data/numbers/1.txt" and writes to a temporary file
+
And I open data/fileselect.html
And I run :click-element id multiple_files
Then the javascript message "Files: 1.txt" should be logged
Scenario: Select two files with multiple command
- When I set up a fake "multiple_files" fileselector selecting "tests/end2end/data/numbers/1.txt tests/end2end/data/numbers/2.txt"
+ When I setup a fake multiple_files fileselector selecting "tests/end2end/data/numbers/1.txt tests/end2end/data/numbers/2.txt" and writes to a temporary file
+
And I open data/fileselect.html
And I run :click-element id multiple_files
Then the javascript message "Files: 1.txt, 2.txt" should be logged
diff --git a/tests/end2end/features/sessions.feature b/tests/end2end/features/sessions.feature
index 0f0c015e0..e48947cbd 100644
--- a/tests/end2end/features/sessions.feature
+++ b/tests/end2end/features/sessions.feature
@@ -395,9 +395,10 @@ Feature: Saving and loading sessions
And I run :session-load -c pin_session
And I wait until data/numbers/3.txt is loaded
And I run :tab-focus 2
- And I run :open hello world
- Then the message "Tab is pinned!" should be shown
+ And I open data/numbers/4.txt
+ Then the message "Tab is pinned! Opening in new tab." should be shown
And the following tabs should be open:
- data/numbers/1.txt
- data/numbers/2.txt (active) (pinned)
+ - data/numbers/4.txt
- data/numbers/3.txt
diff --git a/tests/end2end/features/tabs.feature b/tests/end2end/features/tabs.feature
index ca0efefc4..7db054573 100644
--- a/tests/end2end/features/tabs.feature
+++ b/tests/end2end/features/tabs.feature
@@ -1534,10 +1534,11 @@ Feature: Tab management
Scenario: :tab-pin open url
When I open data/numbers/1.txt
And I run :tab-pin
- And I open data/numbers/2.txt without waiting
- Then the message "Tab is pinned!" should be shown
+ And I open data/numbers/2.txt
+ Then the message "Tab is pinned! Opening in new tab." should be shown
And the following tabs should be open:
- data/numbers/1.txt (active) (pinned)
+ - data/numbers/2.txt
Scenario: :tab-pin open url with tabs.pinned.frozen = false
When I set tabs.pinned.frozen to false
diff --git a/tests/end2end/features/test_editor_bdd.py b/tests/end2end/features/test_editor_bdd.py
index 445691bee..40f77a0f7 100644
--- a/tests/end2end/features/test_editor_bdd.py
+++ b/tests/end2end/features/test_editor_bdd.py
@@ -32,7 +32,7 @@ bdd.scenarios('editor.feature')
from qutebrowser.utils import utils
-@bdd.when(bdd.parsers.parse('I set up a fake editor replacing "{text}" by '
+@bdd.when(bdd.parsers.parse('I setup a fake editor replacing "{text}" by '
'"{replacement}"'))
def set_up_editor_replacement(quteproc, server, tmpdir, text, replacement):
"""Set up editor.command to a small python script doing a replacement."""
@@ -53,7 +53,7 @@ def set_up_editor_replacement(quteproc, server, tmpdir, text, replacement):
quteproc.set_setting('editor.command', editor)
-@bdd.when(bdd.parsers.parse('I set up a fake editor returning "{text}"'))
+@bdd.when(bdd.parsers.parse('I setup a fake editor returning "{text}"'))
def set_up_editor(quteproc, tmpdir, text):
"""Set up editor.command to a small python script inserting a text."""
script = tmpdir / 'script.py'
@@ -67,7 +67,7 @@ def set_up_editor(quteproc, tmpdir, text):
quteproc.set_setting('editor.command', editor)
-@bdd.when(bdd.parsers.parse('I set up a fake editor returning empty text'))
+@bdd.when(bdd.parsers.parse('I setup a fake editor returning empty text'))
def set_up_editor_empty(quteproc, tmpdir):
"""Set up editor.command to a small python script inserting empty text."""
set_up_editor(quteproc, tmpdir, "")
@@ -107,7 +107,7 @@ def editor_pid_watcher(tmpdir):
return EditorPidWatcher(tmpdir)
-@bdd.when(bdd.parsers.parse('I set up a fake editor that writes "{text}" on '
+@bdd.when(bdd.parsers.parse('I setup a fake editor that writes "{text}" on '
'save'))
def set_up_editor_wait(quteproc, tmpdir, text, editor_pid_watcher):
"""Set up editor.command to a small python script inserting a text."""
@@ -180,18 +180,31 @@ def save_editor_wait(tmpdir):
os.kill(pid, signal.SIGUSR2)
-@bdd.when(bdd.parsers.parse('I set up a fake "{kind}" fileselector '
- 'selecting "{files}"'))
-def set_up_fileselector(quteproc, py_proc, kind, files):
+@bdd.when(bdd.parsers.parse('I setup a fake {kind} fileselector '
+ 'selecting "{files}" and writes to {output_type}'))
+def set_up_fileselector(quteproc, py_proc, kind, files, output_type):
"""Set up fileselect.xxx.command to select the file(s)."""
cmd, args = py_proc(r"""
import os
import sys
- tmp_file = sys.argv[1]
- with open(tmp_file, 'w') as f:
- for selected_file in sys.argv[2:]:
- f.write(os.path.abspath(selected_file) + "\n")
+ tmp_file = None
+ for i, arg in enumerate(sys.argv):
+ if arg.startswith('--file='):
+ tmp_file = arg[len('--file='):]
+ sys.argv.pop(i)
+ break
+ selected_files = sys.argv[1:]
+ if tmp_file is None:
+ for selected_file in selected_files:
+ print(os.path.abspath(selected_file))
+ else:
+ with open(tmp_file, 'w') as f:
+ for selected_file in selected_files:
+ f.write(os.path.abspath(selected_file) + '\n')
""")
- fileselect_cmd = json.dumps([cmd, *args, '{}', *files.split(' ')])
+ args += files.split(' ')
+ if output_type == "a temporary file":
+ args += ['--file={}']
+ fileselect_cmd = json.dumps([cmd, *args])
quteproc.set_setting('fileselect.handler', 'external')
quteproc.set_setting(f'fileselect.{kind}.command', fileselect_cmd)
diff --git a/tests/unit/completion/test_models.py b/tests/unit/completion/test_models.py
index 8a6b24557..22e9c6490 100644
--- a/tests/unit/completion/test_models.py
+++ b/tests/unit/completion/test_models.py
@@ -28,7 +28,7 @@ from datetime import datetime
from unittest import mock
import hypothesis
-import hypothesis.strategies
+import hypothesis.strategies as hst
import pytest
from PyQt5.QtCore import QUrl, QDateTime
try:
@@ -459,9 +459,10 @@ def test_filesystem_completion_model_interface(info, local_files_path):
@hypothesis.given(
- as_uri=hypothesis.strategies.booleans(),
- add_sep=hypothesis.strategies.booleans(),
- text=hypothesis.strategies.text(),
+ as_uri=hst.booleans(),
+ add_sep=hst.booleans(),
+ text=hst.text(alphabet=hst.characters(
+ blacklist_categories=['Cc'], blacklist_characters='\x00')),
)
def test_filesystem_completion_hypothesis(info, as_uri, add_sep, text):
if as_uri:
@@ -1445,7 +1446,7 @@ def undo_completion_retains_sort_order(tabbed_browser_stubs, info):
_check_completions(model, {"Closed tabs": expected})
-@hypothesis.given(text=hypothesis.strategies.text())
+@hypothesis.given(text=hst.text())
def test_listcategory_hypothesis(text):
"""Make sure we can't produce invalid patterns."""
cat = listcategory.ListCategory("test", [])
diff --git a/tests/unit/misc/test_guiprocess.py b/tests/unit/misc/test_guiprocess.py
index a2acad1ac..9e1b3916c 100644
--- a/tests/unit/misc/test_guiprocess.py
+++ b/tests/unit/misc/test_guiprocess.py
@@ -127,9 +127,11 @@ def test_start_output_message(proc, qtbot, caplog, message_mock, py_proc,
if stdout_msg is not None:
assert stdout_msg.level == usertypes.MessageLevel.info
assert stdout_msg.text == 'stdout text'
+ assert proc.final_stdout.strip() == "stdout text", proc.final_stdout
if stderr_msg is not None:
assert stderr_msg.level == usertypes.MessageLevel.error
assert stderr_msg.text == 'stderr text'
+ assert proc.final_stderr.strip() == "stderr text", proc.final_stderr
def test_start_env(monkeypatch, qtbot, py_proc):