diff --git a/.flake8 b/.flake8 index d967a505b..14fd08034 100644 --- a/.flake8 +++ b/.flake8 @@ -42,6 +42,8 @@ putty-ignore = tests/helpers/fixtures.py : +N806 tests/unit/browser/webkit/http/test_content_disposition.py : +D400 scripts/dev/ci/appveyor_install.py : +FI53 + # FIXME:conf + tests/unit/completion/test_models.py : +F821 copyright-check = True copyright-regexp = # Copyright [\d-]+ .* copyright-min-file-size = 110 diff --git a/scripts/dev/src2asciidoc.py b/scripts/dev/src2asciidoc.py index df561567c..09e083e79 100755 --- a/scripts/dev/src2asciidoc.py +++ b/scripts/dev/src2asciidoc.py @@ -356,9 +356,33 @@ def generate_commands(filename): f.write(_get_command_doc(name, cmd)) +def _generate_setting_backend_info(f, opt): + """"Generate backend information for the given option.""" + all_backends = [usertypes.Backend.QtWebKit, usertypes.Backend.QtWebEngine] + if opt.raw_backends is not None: + for name, conditional in sorted(opt.raw_backends.items()): + if conditional is True: + pass + elif conditional is False: + f.write("\nOn {}, this setting is unavailable.\n".format(name)) + else: + f.write("\nOn {}, this setting requires {} or newer.\n" + .format(name, conditional)) + elif opt.backends == all_backends: + pass + elif opt.backends == [usertypes.Backend.QtWebKit]: + f.write("\nThis setting is only available with the QtWebKit " + "backend.\n") + elif opt.backends == [usertypes.Backend.QtWebEngine]: + f.write("\nThis setting is only available with the QtWebEngine " + "backend.\n") + else: + raise ValueError("Invalid value {!r} for opt.backends" + .format(opt.backends)) + + def _generate_setting_option(f, opt): """Generate documentation for a single section.""" - f.write("\n") f.write('[[{}]]'.format(opt.name) + "\n") f.write("== {}".format(opt.name) + "\n") @@ -386,27 +410,7 @@ def _generate_setting_option(f, opt): else: f.write("Default: empty\n") - all_backends = [usertypes.Backend.QtWebKit, usertypes.Backend.QtWebEngine] - if opt.raw_backends is not None: - for name, conditional in sorted(opt.raw_backends.items()): - if conditional is True: - pass - elif conditional is False: - f.write("\nOn {}, this setting is unavailable.\n".format(name)) - else: - f.write("\nOn {}, this setting requires {} or newer.\n" - .format(name, conditional)) - elif opt.backends == all_backends: - pass - elif opt.backends == [usertypes.Backend.QtWebKit]: - f.write("\nThis setting is only available with the QtWebKit " - "backend.\n") - elif opt.backends == [usertypes.Backend.QtWebEngine]: - f.write("\nThis setting is only available with the QtWebEngine " - "backend.\n") - else: - raise ValueError("Invalid value {!r} for opt.backends" - .format(opt.backends)) + _generate_setting_backend_info(f, opt) def generate_settings(filename): diff --git a/tests/helpers/stubs.py b/tests/helpers/stubs.py index 82b88dd74..fb1232396 100644 --- a/tests/helpers/stubs.py +++ b/tests/helpers/stubs.py @@ -389,6 +389,8 @@ class InstaTimer(QObject): class FakeYamlConfig: + """Fake configfiles.YamlConfig object.""" + def __init__(self): self.values = {} self.loaded = False diff --git a/tests/unit/config/test_config.py b/tests/unit/config/test_config.py index 1a67ed5fb..b365914f7 100644 --- a/tests/unit/config/test_config.py +++ b/tests/unit/config/test_config.py @@ -275,14 +275,14 @@ class TestSetConfigCommand: objreg.delete('tabbed-browser', scope='window', window=0) def test_set_no_args(self, commands, tabbed_browser): - """:set + """Run ':set'. Should open qute://settings.""" commands.set(win_id=0) assert tabbed_browser.opened_url == QUrl('qute://settings') def test_get(self, config_stub, commands, message_mock): - """:set url.auto_search? + """Run ':set url.auto_search?'. Should show the value. """ @@ -293,7 +293,7 @@ class TestSetConfigCommand: @pytest.mark.parametrize('temp', [True, False]) def test_set_simple(self, monkeypatch, commands, config_stub, temp): - """:set [-t] url.auto_search dns + """Run ':set [-t] url.auto_search dns'. Should set the setting accordingly. """ @@ -326,7 +326,7 @@ class TestSetConfigCommand: assert config_stub._yaml.values['url.auto_search'] == 'dns' def test_set_print(self, config_stub, commands, message_mock): - """:set -p url.auto_search never + """Run ':set -p url.auto_search never'. Should set show the value. """ @@ -338,7 +338,7 @@ class TestSetConfigCommand: assert msg.text == 'url.auto_search = dns' def test_set_toggle(self, commands, config_stub): - """:set auto_save.config! + """Run ':set auto_save.config!'. Should toggle the value. """ @@ -348,7 +348,7 @@ class TestSetConfigCommand: assert not config_stub._yaml.values['auto_save.config'] def test_set_toggle_nonbool(self, commands, config_stub): - """:set url.auto_search! + """Run ':set url.auto_search!'. Should show an error """ @@ -359,7 +359,7 @@ class TestSetConfigCommand: assert config_stub.val.url.auto_search == 'naive' def test_set_toggle_print(self, commands, config_stub, message_mock): - """:set -p auto_save.config! + """Run ':set -p auto_save.config!'. Should toggle the value and show the new value. """ @@ -368,7 +368,7 @@ class TestSetConfigCommand: assert msg.text == 'auto_save.config = false' def test_set_invalid_option(self, commands): - """:set foo bar + """Run ':set foo bar'. Should show an error. """ @@ -376,7 +376,7 @@ class TestSetConfigCommand: commands.set(0, 'foo', 'bar') def test_set_invalid_value(self, commands): - """:set auto_save.config blah + """Run ':set auto_save.config blah'. Should show an error. """ @@ -394,7 +394,7 @@ class TestSetConfigCommand: @pytest.mark.parametrize('option', ['?', '!', 'url.auto_search']) def test_empty(self, commands, option): - """:set ? / :set ! / :set url.auto_search + """Run ':set ?' / ':set !' / ':set url.auto_search'. Should show an error. See https://github.com/qutebrowser/qutebrowser/issues/1109 @@ -406,7 +406,7 @@ class TestSetConfigCommand: @pytest.mark.parametrize('suffix', '?!') def test_invalid(self, commands, suffix): - """:set foo? / :set foo! + """Run ':set foo?' / ':set foo!'. Should show an error. """ @@ -422,7 +422,7 @@ class TestSetConfigCommand: ('red', 'green'), ]) def test_cycling(self, commands, config_stub, initial, expected): - """:set with multiple values.""" + """Run ':set' with multiple values.""" opt = 'colors.statusbar.normal.bg' config_stub.set_obj(opt, initial) commands.set(0, opt, 'green', 'magenta', 'blue', 'yellow') @@ -472,7 +472,7 @@ class TestBindConfigCommand: ]) def test_bind_print(self, commands, config_stub, message_mock, key, mode, expected): - """:bind key + """Run ':bind key'. Should print the binding. """ @@ -500,7 +500,7 @@ class TestBindConfigCommand: ('nop', 'wrongmode', "bind: Invalid mode wrongmode!"), ]) def test_bind_invalid(self, commands, command, mode, expected): - """:bind a foobar / :bind a completion-item-del + """Run ':bind a foobar' / ':bind a completion-item-del'. Should show an error. """ @@ -510,7 +510,7 @@ class TestBindConfigCommand: @pytest.mark.parametrize('force', [True, False]) @pytest.mark.parametrize('key', ['a', 'b', '']) def test_bind_duplicate(self, commands, config_stub, keyconf, force, key): - """:bind a key which already has been bound. + """Run ':bind' with a key which already has been bound.'. Also tests for https://github.com/qutebrowser/qutebrowser/issues/1544 """ @@ -566,7 +566,7 @@ class TestBindConfigCommand: ('x', 'wrongmode', "unbind: Invalid mode wrongmode!"), ]) def test_unbind_invalid(self, commands, key, mode, expected): - """:unbind foobar / :unbind x wrongmode + """Run ':unbind foobar' / ':unbind x wrongmode'. Should show an error. """ diff --git a/tests/unit/config/test_configtypes.py b/tests/unit/config/test_configtypes.py index 33ddaec95..677045a60 100644 --- a/tests/unit/config/test_configtypes.py +++ b/tests/unit/config/test_configtypes.py @@ -1566,8 +1566,7 @@ class TestFile: os_mock.path.isabs.return_value = True assert klass().to_py('$HOME/foobar') == '/home/foo/foobar' - def test_to_py_invalid_encoding(self, klass, os_mock, - unicode_encode_err): + def test_to_py_invalid_encoding(self, klass, os_mock, unicode_encode_err): """Test to_py with an invalid encoding, e.g. LC_ALL=C.""" os_mock.path.isfile.side_effect = unicode_encode_err os_mock.path.isabs.side_effect = unicode_encode_err diff --git a/tests/unit/mainwindow/test_prompt.py b/tests/unit/mainwindow/test_prompt.py index 8e0470f6b..76886d340 100644 --- a/tests/unit/mainwindow/test_prompt.py +++ b/tests/unit/mainwindow/test_prompt.py @@ -32,6 +32,7 @@ class TestFileCompletion: def get_prompt(self, qtbot, config_stub, key_config_stub): """Get a function to display a prompt with a path.""" config_stub.val.bindings.default = {} + def _get_prompt_func(path): question = usertypes.Question() question.title = "test"