unix_filename_rubout deletes to the previous slash or whitespace,
unlike the previously implemented backwards-kill-word which treats and
non-alphanumeric character as a boundary.
To illustrate, given the text 'foo/bar.baz', unix_filename_rubout will
delete 'bar.baz' while backwards-kill-word will delete only 'baz'.
See #1710.
This restores the previous behavior of `unix-word-rubout` as
`backward-kill-word`, which is closer to the naming used in readline.
It is bound to <Alt-Backspace> by default, though <Ctrl-Backspace> will
also work due to a builtin binding.
Resolves#1698.
These commands are more closely tied to the CompletionView than
Completer. This removes the need for an extra signal tying the
CompletionView to the Completer.
The call to _open_completion_if_needed was moved to
on_selection_changed, as this will already be called when a new item is
selected.
Rather than having a CompletionView instantiate and register a
Completer, instantiate both in MainWindow. The CompletionView is the
parent of the Completer, and communicates by emitting
selection_changed, meaning it no longer needs to contain a reference to
the Completer.
- clean up docstring typos
- use _ to name an unused loop variable
- parent the filter model to avoid an issue with disposal
- use mocker.patch instead of monkeypatch to mock Completer creation
- use is instead of == to compare by identity
The CompletionView looks in objreg for 'status-cmd', so move it from a
private fixture in test_completer to a public fixture that handles
objreg registration/deletion.
update_completion is only used internally, so instead test the real
public entry point which is schedule_completion_update.
This required mocking out QTimer to fire immediately so the test didn't
have to do flaky artificial delays.
There's currently an error on exit which doesn't get caught with
--nowindow and not with ":later 500 quit".
We also need to check the output as there's an additional segfault when
that happens...
* Move documentation changes of bookmark / quickmarks to docstrings, as the
asciidoc is autogenerated from those
* Fix some whitespaces in the BDD test cases
* Improved docstring in qute_bookmarks handler
There is a new page now, qute:bookmarks that will display all bookmarks and
quickmarks. It's still missing a search / filter feature, but you can use
the built-in search / navigation just as easily for now.
The message mock might handle a message during pytest-qt's processEvents
during test setup. If that happens, depending on the fixture order,
pytest-caplog might not be set up first, which is why the
self._caplog.at_level call can fail:
File "c:\projects\qutebrowser\qutebrowser\misc\guiprocess.py", line 105, in on_finished
immediately=True)
File "C:\projects\qutebrowser\tests\helpers\messagemock.py", line 71, in _handle_error
self._handle(Level.error, *args, **kwargs)
File "C:\projects\qutebrowser\tests\helpers\messagemock.py", line 65, in _handle
with self._caplog.at_level(log_level): # needed so we don't fail
File "C:\projects\qutebrowser\.tox\py34\lib\site-packages\pytest_catchlog.py", line 232, in at_level
obj = logger and logging.getLogger(logger) or self.handler
File "C:\projects\qutebrowser\.tox\py34\lib\site-packages\pytest_catchlog.py", line 186, in handler
return self._item.catch_log_handler
AttributeError: 'Function' object has no attribute 'catch_log_handler'
Full stack:
c:\projects\qutebrowser-git\.tox\py34\lib\site-packages\pytestqt\plugin.py(100)pytest_runtest_setup()
-> _process_events()
c:\projects\qutebrowser-git\.tox\py34\lib\site-packages\pytestqt\plugin.py(140)_process_events()
-> app.processEvents()
c:\projects\qutebrowser-git\qutebrowser\misc\guiprocess.py(94)on_error()
-> self._what, msg), immediately=True)
c:\projects\qutebrowser-git\tests\helpers\messagemock.py(71)_handle_error()
-> self._handle(Level.error, *args, **kwargs)
c:\projects\qutebrowser-git\tests\helpers\messagemock.py(65)_handle()
-> with self._caplog.at_level(log_level): # needed so we don't fail
c:\projects\qutebrowser-git\.tox\py34\lib\site-packages\pytest_catchlog.py(235)at_level()
-> obj = logger and logging.getLogger(logger) or self.handler
> c:\projects\qutebrowser-git\.tox\py34\lib\site-packages\pytest_catchlog.py(189)handler()->None
This should fix broken AppVeyor builds.
Fixes#1662.
Using the config_tmdpir fixture across all tests in this module caused
a lingering LineParser to make test_debug fail.
I still don't know why, but scoping the config_tmpdir fixture to only
the test class that was creating ~/.config/qute_test fixes the issue,
and still prevents creation of a user tempdir.
This was more complicated than the other data/config/cachedir test
fixes, as QtWebEngine was accessing the datadir directly (and bypassing
standdarddir.data).
This means the tmpdir_data stub is not enough, we need to set
XDG_DATA_HOME to redirect access.
Don't create ~/.config/qute_test by mocking out standdarddir.config for
all tests in this module.
This adds config_tmpdir to fixtures.py and moves temp_datadir from
test_adblock to fixtures.py as it will be needed more broadly.
Running test_standarddir would pollute the user's home with
`~/.cache/qute_test`.
The `no_cachedir_tag` fixture was supposed to prevent this, but was not
working because [usefixtures does not work on fixtures]
(https://github.com/pytest-dev/pytest/issues/1014).
This fixes the fixture to actually prevent cachedir creation, but
applies it to tests individually (or by class) rather than with autouse
because the cachedir tests cannot pass if it is working.
Running the tests would create ~/.config/qute_test and
~/.local/share/qute_test on the user's machine. The test_standardir
module needed a bit more mocking to prevent it from cluttering the
user's machine.
Two tests that created the data dir were fixed by passing basedir in
args, and one test that created the config dir was fixed by patching
os.makedirs to a noop.
In the last CherryPy update, cherrypy.wsgiserver got converted to a
single module. While this issue still exists in pylint, we don't get it
here anymore.
We have some things like pos_px stubbed which will fail any test because
of the stub warning - but some tests don't actually need that, it just
happens when e.g. loading something.
So let's not fail tests based on stub warnings, and see how much works
that way.
Per one of the diff comments on #1597:
> I used to use a tuple for constant things, but nowadays I'd actually
> prefer a list as a tuple is something more heterogeneous (i.e. it
> makes sense to have a `(x, y)` point as a tuple, but a list of points
> would be a list).
> At some point I should probably change it to a list everywhere 😉
The test was failing because of two reasons:
First, the old code had filename questions in DownloadManager.get and
DownloadManager.fetch which were almost identical, thus the part in
DownloadManager.get was removed in an earlier commit. All filename
asking is now done by DownloadManager.fetch. The good part is code
deduplication, the bad part is slightly modified behavior: The new code
doesn't wait for a filename to start the download, instead it tries to
fill the buffer immediately. This made the test fail because qute:// has
no registered handler, so in order for the test to pass now, the "no
crash" part is not enough, we also need to expect the "No handler"
error.
Secondly, and a rather rare (race) condition was the handling of errors
in the DownloadItem. If an error occured after the registration of
self.on_reply_error as error handler and before the check
reply.error() != QNetworkReply.NoError
at the end of the function, the error signal would be emitted twice:
Once by _die() (called by on_reply_error), and once by the init_reply
function directly (in the last if block). This lead to duplicated error
messages. This is also explained in a comment in the file (with small
"stack traces").
- The invalid URL will now get encoded when using QUrl.
- The check for a None url_text is somewhat pointless as I don't think
this can ever happen in the real circumstances.
There'll be a refactoring to add a session API to WebTab later anyways,
so no point in fixing this now.
As many tests as possible here should probably also be changed to
end2end ones as there's a lot of mocking going on.
For the Completer unit tests:
Although `change_completed_part` looks like a public method, it was
only used internally. Test the externally-used method
`selection_changed` instead.
Based on code review:
- Use qtbot.waitSignal to test a signal firing
- Use pytest.mark.xfail for an expected test failure
- Ensure there are 2 newlines between module-level functions
Based on code review:
- import modules, not classes
- use methods, not lambdas for the mock command prompt class
- use None rather than Mock for DUMB_SORT
- autouse two fixtures and remove them from test signatures
Fixes#1611
This marks errors that are expected by a test with an "(Expected)"
marker and white color (instead of red).
The formatting of the log messages has been deferred to _render_log,
since the .expected attribute is not correctly set right after we read
the message.
Had to add the `raw` parameter to ConfigStub.get as the setting option
completion model passes this argument explicitly (although the docs say
only raw=True is supported).
* Don't flag attributes as unused if they are used as global variables in
another module.
* Don't consider "True" and "False" variable names.
* Abort with error message when invoked on .pyc files.
This means we can remove the whitelisted globals in run_vulture.py and
the associated xfailing test.
We also needed to adjust run_vulture.py slightly as the file attribute
got renamed to filename.
When a redirect occurs, the item is saved in history with a -r suffix
now. When opening qutebrowser that's picked up and the item is hidden
from completion.
This makes it possible to switch to an alternative implementation if
there are weird issues like #1568. Some users might also prefer the
slightly better performance over more accurate hints.
For some reason the behaviour of QHostAddress("31c3").isValid() changed
with Qt 5.6.1: https://bugreports.qt.io/browse/QTBUG-53983
This causes the test to fail because Qt thinks this is a valid IP, so we
think it's a valid URL.
For some reason, sometimes on Travis the history file we read is empty.
I have no idea why though, as we successfully wait until ":save saved
history" is logged, and that is working fine.
Let's just mark the test as flaky for now so we can move on.
Clicking actually works fine without the strip() as _resolve_url is
never called in that case, so we need to do something which actually
needs the URL as well.
There were two different issues here:
- `\n` rather than `os.linesep` was used, which caused the "generated"
file to have less data in it than expected
- A final `os.linesep` (or `\n`) was missing, but that was cancelled out
by a off-by-one error when slicing, so wasn't an issue until we tried
with \r\n endings.
Otherwise history tests could fail because waiting for
"Saved to *history" waited for a previous line, not the newest one.
It also doesn't make any sense to save stuff anyways.
Load all special keystrings (e.g. <ctrl-a>) into memory as lowercase,
and automatically lowercase any special keystring given to bind/unbind.
This prevents <ctrl-a> and <Ctrl-A> from being treated differently.
Resolves#816.
Also resolves#1544 (dupe).
In various situations (especially on OS X), pytest segfaults on exit probably
due to Qt/PyQt bugs.
We now have a wrapper script which ignores those segfaults if pytest did run
successfully.
On OS X, sometimes the userscript exited before the QSocketNotifier was
triggered. By doing a final read when cleaning up we make sure we don't
miss anything.
Fixes#1533.
When doing quteproc.open_path, by default the test didn't wait until the page
was loaded. This caused unintentional race conditions which e.g. caused
dirbrowser tests to fail on OS X:
https://travis-ci.org/The-Compiler/qutebrowser/jobs/133730001
Now instead we wait by default, unless wait=False is passed to open_path() or
open_url().
Otherwise if we only run a keypress test, the fake clipboard won't be
activated and thus the subsequent :yank-selected would write to the real
clipboard.
When using flake8-string-format on Python 3.5 with str.format(*group) it
failed:
Traceback (most recent call last):
File "./.venv-flakes/bin/flake8", line 11, in <module>
sys.exit(main())
File ".../site-packages/flake8/main.py", line 33, in main
report = flake8_style.check_files()
File ".../site-packages/flake8/engine.py", line 181, in check_files
return self._retry_serial(self._styleguide.check_files, paths=paths)
File ".../site-packages/flake8/engine.py", line 172, in _retry_serial
return func(*args, **kwargs)
File ".../site-packages/pep8.py", line 1842, in check_files
runner(path)
File ".../site-packages/flake8/engine.py", line 126, in input_file
return fchecker.check_all(expected=expected, line_offset=line_offset)
File ".../site-packages/pep8.py", line 1574, in check_all
self.check_ast()
File ".../site-packages/pep8.py", line 1521, in check_ast
for lineno, offset, text, check in checker.run():
File ".../site-packages/flake8_string_format.py", line 288, in run
assert isinstance(call.args, ast.Starred) is bool(has_starargs)
AssertionError
This works around that issue.
See https://github.com/xZise/flake8-string-format/issues/11
Replace the setting ui.show-keyhints with ui.keyhint-blacklist, which
is a list of globs for keychains that shouldn't be hinted. This allows
users to prevent showing keyhints for keychains they already know.
keyhint-blacklist='*' is equivalent to show-keyhints=False.
Resolves#1515.
If a user knows the keychain and can type it quickly, we shouldn't
annoy them with a popup. Only show the keyhint if the user doesn't
complete their keychain in 500ms.
The isVisible() check in the tests is somewhat invalid now because it
is never immediately visible and I don't want to add a delay to unit
tests. I added a check that text() is not set for one test that was
only checking isVisible().
Addresses part of #1515.
Validate the hint spawn fix as well as add feature tests for previously
untested hinting behaviors (fill, run, --rapid).
There is still no test for the 'userscript' target as running a
userscript from hint mode during a test does not get the same
redirection as the 'I execute the userscript ...' statement, That is,
it looks in /usr/local/share/qutebrowser/userscripts rather than
tests/integration/data/userscripts.
This supports things like :hint all spawn -v echo as '-v echo' will be
passed as a single unit to spawn rather than -v being interpreted as a
flag for :hint.
Resolves#797.
Note that, while `:hint --rapid all spawn -v` echo works,
`:hint all --rapid spawn -v echo` does not (this did not work before
either).
Instead of creating a new guiprocess manually, just pass the args along
to the spawn command so it can accept args like -v.
Addresses part of #797 by allowing `hint -- all spawn -v echo`.
`hint all spawn -v echo` is still not supported.
The check `key.startswith('<') and key.endswith('>') is repeated many
times in code to check for a special key. Replace all these with a call
to the same function.
Currently, the keyhint window is shown even if the keystring matches no
possible bindings. This causes an empty keyhint window to hang around
after entering hinting mode.
Instead, the window is now hidden if no bindings match the current
keystring.
Resolves#1507.
Since we're not using those functions as argparse callbacks anymore, we
can write a normal function instead of factories, which simplifies
things a lot.
This means:
- An annotation like (int, str) is now typing.Union[int, str].
- utils.typing got expanded so it acts like the real typing.py, with
issubclass() working properly with typing.Union and __union_params__
being set.
- A literal string doesn't exist anymore as annotation, instead
@cmdutils.argument now has a 'choices' argument which can be used like
@cmdutils.argument('arg', choices=['val1', 'val2']).
- Argument validating/converting is now entirely handled by
argparser.type_conv instead of relying on python's argparse, i.e.
type/choices is now not passed to argparse anymore.
TestArgument didn't clear the globals as the fixture was inside
TestRegister.
This means test_run_vulture failed in funny ways because run_vulture.py
generated a whitelist containing "<locals>" for commands:
tests/unit/scripts/test_run_vulture.py:55: in run
return run_vulture.run([str(e.basename) for e in files])
scripts/dev/run_vulture.py:146: in run
vult.scavenge(files + [whitelist_file.name])
.tox/py35/lib/python3.5/site-packages/vulture.py:107: in scavenge
self.scan(module_string)
.tox/py35/lib/python3.5/site-packages/vulture.py:75: in scan
node = ast.parse(node_string, filename=self.file)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
source = 'qutebrowser.browser.commands.CommandDispatcher.buffer\nqutebrowser.misc.savemanager.SaveManager.save_command\nqutebro...iidoc.UsageFormatter._get_default_metavar_for_positional\nscripts.dev.src2asciidoc.UsageFormatter._metavar_formatter\n'
filename = '/tmp/tmp_ein2umn', mode = 'exec'
def parse(source, filename='<unknown>', mode='exec'):
"""
Parse the source into an AST node.
Equivalent to compile(source, filename, mode, PyCF_ONLY_AST).
"""
> return compile(source, filename, mode, PyCF_ONLY_AST)
E File "/tmp/tmp_ein2umn", line 16
E test_cmdutils.TestArgument.test_wrong_order.<locals>.fun
E ^
E SyntaxError: invalid syntax
Change the unit tests to expect the new tabular format.
Also generally clean up the tests -- refactor from a class to
module-level functions as there was no need for a class here.
- validate keyhint text for a partial keychain
- ensure special keybindings are not suggested
- ensure it is not visible when disabled
- ensure changes to the suffix color are picked up
Implement mock_key_config.set_bindings_for to set bindings that will be
retrieved by mock_key_config.get_bindings_for.
This is useful for testing the new keyhint ui.
This failed because dict.get('level') returned None with no level
parameter, and the subsequent [0] raised:
Traceback (most recent call last):
File ".../qutebrowser/utils/utils.py", line 624, in wrapper
return func(*args, **kwargs)
File ".../qutebrowser/browser/network/networkmanager.py", line 445, in createRequest
op, req, outgoing_data)
File ".../qutebrowser/browser/network/qutescheme.py", line 107, in createRequest
data = handler(self._win_id, request)
File ".../qutebrowser/browser/network/qutescheme.py", line 189, in qute_log
level = urllib.parse.parse_qs(request.url().query()).get('level')[0]
TypeError: 'NoneType' object is not subscriptable
- Add log.LOG_LEVELS to map names to levels (instead of using
logging._levelToName)
- Test that log pages do not contain messages below the requested level
- Use pythons urllib.parse.parse_qs instead of Qt's UrlQuery
- Document tab, bg, window args for :messages
- Clean up style
This adds a 'level' query parameter to qute://log and qute://plainlog.
For example, qute://log?level=warning will show an html page containing
log entries with severity warning or greater.
If the query is omitted, the original behavior of qute://log is
preserved.
:messages [level] is a command that opens qute://log?level=<level>.
By default, level defaults to 'error' as an easy way to see missed
error messages.
colorlog was problematic for various reasons:
- Not commonly packaged for Linux distributions
- Calling colorama.init() automatically on import
- Not supporting {foo} log formatting
- Not supporting an easy way to turn colors off
Instead we now do the log coloring by hand, which is simpler and means
everyone will have colored logs.
An unique keybinding for each test means we have some level of
isolation and can understand error messages more easily.
As we're >10 now, let's use a leading zero to avoid shadowed
keybindings.
Issue 1413
This happens when the networkmanager is used by something that has no
tab_id, like the generic DownloadManager. In this case, we should just
skip the webview connection (as it makes no sense) instead of crashing
(which is the last thing we want to do).
The <command> arg is now optional. If omitted, :bind prints the current
binding as a message. If --mode is given, the binding for that mode is
printed.
Allow a variable amount of whitespace for rgb, rgba, hsv, and hsva
strings in the config.
Previously only 'rgb(0, 0, 0)' was allowed. Now things like
'rgb(0,0,0)' are permitted.
The repeated 3-digit segments of the regexes were separated out to
reduce repetition and line length.
--cachedir="" doesn't work because the quotes are not processed (as they
would be by the shell) and the cachedir is set to ./"" (that is a
directory with two double quotes as name). The correct start parameter
is thus --cachedir=, which correctly fails when the fix is reverted.
When using :tab-prev/:tab-next (or :tab-focus which uses :tab-next
internally) immediately after the last tab, those functions could be
called with 0 tabs open, which caused a ZeroDivisionError when trying to
do % 0.
Fixes#1448.