SQL code review fixes.

- 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
This commit is contained in:
Ryan Roden-Corrent 2017-07-12 08:19:31 -04:00
parent 182d067ff8
commit ea459a1eca
5 changed files with 11 additions and 3 deletions

View File

@ -11,6 +11,7 @@ exclude = .*,__pycache__,resources.py
# (for pytest's __tracebackhide__) # (for pytest's __tracebackhide__)
# F401: Unused import # F401: Unused import
# N802: function name should be lowercase # N802: function name should be lowercase
# N806: variable in function should be lowercase
# P101: format string does contain unindexed parameters # P101: format string does contain unindexed parameters
# P102: docstring does contain unindexed parameters # P102: docstring does contain unindexed parameters
# P103: other string does contain unindexed parameters # P103: other string does contain unindexed parameters
@ -27,7 +28,7 @@ exclude = .*,__pycache__,resources.py
ignore = ignore =
E128,E226,E265,E501,E402,E266,E722,E731, E128,E226,E265,E501,E402,E266,E722,E731,
F401, F401,
N802, N802,N806
P101,P102,P103, P101,P102,P103,
D102,D103,D104,D105,D209,D211,D402,D403 D102,D103,D104,D105,D209,D211,D402,D403
min-version = 3.4.0 min-version = 3.4.0

View File

@ -290,6 +290,8 @@ class CompletionView(QTreeView):
self.expand(model.index(i, 0)) self.expand(model.index(i, 0))
def set_pattern(self, pattern): def set_pattern(self, pattern):
if not self.model():
return
self.pattern = pattern self.pattern = pattern
with debug.log_time(log.completion, 'Set pattern {}'.format(pattern)): with debug.log_time(log.completion, 'Set pattern {}'.format(pattern)):
self.model().set_pattern(pattern) self.model().set_pattern(pattern)

View File

@ -490,6 +490,7 @@ class ModelValidator:
def __init__(self, modeltester): def __init__(self, modeltester):
modeltester.data_display_may_return_none = True modeltester.data_display_may_return_none = True
self._model = None
self._modeltester = modeltester self._modeltester = modeltester
def set_model(self, model): def set_model(self, model):

View File

@ -20,7 +20,6 @@
"""Tests for the global page history.""" """Tests for the global page history."""
import logging import logging
import os
import pytest import pytest
from PyQt5.QtCore import QUrl from PyQt5.QtCore import QUrl

View File

@ -89,6 +89,11 @@ def test_set_pattern(completionview):
model.set_pattern.assert_called_with('foo') model.set_pattern.assert_called_with('foo')
def test_set_pattern_no_model(completionview):
"""Ensure that setting a pattern with no model does not fail."""
completionview.set_pattern('foo')
def test_maybe_update_geometry(completionview, config_stub, qtbot): def test_maybe_update_geometry(completionview, config_stub, qtbot):
"""Ensure completion is resized only if shrink is True.""" """Ensure completion is resized only if shrink is True."""
with qtbot.assertNotEmitted(completionview.update_geometry): with qtbot.assertNotEmitted(completionview.update_geometry):
@ -233,4 +238,4 @@ def test_completion_item_del_no_selection(completionview):
completionview.set_model(model) completionview.set_model(model)
with pytest.raises(cmdexc.CommandError, match='No item selected!'): with pytest.raises(cmdexc.CommandError, match='No item selected!'):
completionview.completion_item_del() completionview.completion_item_del()
func.assert_not_called() assert not func.called