Get qutebrowser to the point where it can at least start
- Declare _messages earlier in MessageView.__init__ so it is set before
the config trigger tries to access it.
- Remove unused configmodel completion functions
- Move bind completion to configmodel to avoid a circular import with
the config module
- Fix some config accesses (forgot to use .val)
- Fix old Completion.CompletionKind references
- Ignore invalid variable name in flake8 (pylint already checks this and
we don't want to have to double-ignore)
- Fix and test completion bug with `:set asdf `
- Remove unused import
- Use `assert not func.called` instead of `func.assert_not_called` for
backwards compatibility
- use mocker.Mock instead of mock.Mock to avoid an extra import
- attach model to validator sooner so it can validate changes in the
model during the test
- remove outdated comment
- fix sql init error message
- clean up history text import code
- fix test_history file path in coverage check
- use real web history, not stub, for completion model tests
- use qtmodeltester in sql/list_category tests
- test url encoding in history tests
- fix test_clear by using a callable mock
- remove test_debug_dump_history_oserror as the check is now the same as
for the file not existing
- rename nonempty to data in test_completionmodel
- add more delete_cur_item tests
- test empty option/value completion
Taking the completion widget as an argument was overly complex.
The process now looks like:
1. CompletionView gets deletion request
2. CompletionView passes selected index to CompletionModel
3. CompletionModel passes the row data to the owning category
4. The category runs its custom completion function.
This also fixes a bug. With the switch to the hybrid (list/sql)
completion model, the view was no longer updating when items were
deleted. This fixes that by ensuring the correct signals are emitted.
The SQL model must be refreshed by running the query. We could try using
a SqlTableModel so we can call removeRows instead.
The test for deleting a url fails because qmodeltester claims the length
of the query model is still 3.
The history completion query is extended to pick only the most recent item for
a given url.
The tests in test_models now check for ordering of elements.
Instead of reading sqlite history from a file and storing it in an in-memory
database, just directly use an on-disk database. This resolves#755, where
history entries don't pop in to the completion menu immediately as they are
still being read asynchronously for a few seconds after the browser starts.
Instead of add_list and add_sqltable, the completion model now supports
add_category, and callees either pass in a SqlCategory or ListCategory. This
makes unit testing much easier.
This also folds CompletionFilterModel into the ListCategory class.
Respond to the low-hanging code review fruit:
- Clean up some comments
- Remove an acidentally added duplicate init_autosave
- Combine two test_history tests
- Move test_init cleanup into a fixture to ensure it gets called.
- Name the _ argument of bind(_) to _key
- Ensure index is valid for first_item/last_item
- Move SqlException to top of module
- Rename test_index to test_getitem
- Return QItemFlags.None instead of None
- Fix copyright dates (its 2017 now!)
- Use * to force some args to be keyword-only
- Make some returns explicit
- Add sql to LOGGER_NAMES
- Add a comment to explain the sql escape statement
- Adjust _check_completions to work for CompletionModel and SqlCompletionModel
- Move sql initialization into a reusable fixture
- Remove the bookmark/quickmark/history stubs, as they're now handled by sql
- Disable quickmark/bookmark model tests until their completion is ported to
sql.
- Disable urlmodel tests for features that have to be implemented in SQL:
- LIMIT (for history-max-items)
- Configurable column order (for quickmarks)
- Configurable formatting (for timestamp-format
The following methods were only used for hint labels and thus removed
now:
- document_element
- create_inside
- find_first
- set_inner_xml
- remove_from_document
- set_style_property
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.
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.
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.
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
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).
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.
Functions now return a PartialCompareOutcome to attach an error message instead
of a bool, and the main function got rewritten based on a handler dict.