Commit Graph

563 Commits

Author SHA1 Message Date
Stefan Tatschner
2c7dc6ffcc Add invalid url to 'test_set_hover_url_encoded'
This covers the recently introduced code path, in 1c23815 (Fix crash
when hovering over an invalid URL, 2016-05-18) when hovering an
invalid URL.
2016-05-18 22:23:26 +02:00
Florian Bruhin
d0af80fbd5 Merge branch 'keystring' of https://github.com/rcorre/qutebrowser into rcorre-keystring 2016-05-18 07:33:17 +02:00
Florian Bruhin
324fcfadb0 Merge branch 'hint_inputs' of https://github.com/Liambeguin/qutebrowser into Liambeguin-hint_inputs 2016-05-18 07:30:46 +02:00
Florian Bruhin
02cbc2f986 Merge branch 'pretty-hover-url' of https://github.com/forkbong/qutebrowser into forkbong-pretty-hover-url 2016-05-18 07:27:30 +02:00
Florian Bruhin
e4d84b0bfc Simplify argparser.type_check
If the value isn't param.default, it will always be a string or a flag, as
type_conv never gets called when the function is called from Python.
2016-05-18 07:16:17 +02:00
Florian Bruhin
a83bf9c3ee Simplify argparser.type_conv
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.
2016-05-18 06:55:27 +02:00
Florian Bruhin
c0d044447d Add tests for qutebrowser.utils.typing 2016-05-18 06:55:17 +02:00
Florian Bruhin
6ed9b6b13f Make sure typing.Union[str, int] gets handled
str always needs to be the last element checked as otherwise it'd always
win.
2016-05-18 06:55:17 +02:00
Florian Bruhin
a0d0b6464f Use typing.py-like annotations for command args
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.
2016-05-18 06:55:17 +02:00
Florian Bruhin
3a33bc42a6 Add initial support for the typing module 2016-05-18 06:55:17 +02:00
Florian Bruhin
9694374673 Add test for cmd arg types 2016-05-18 06:55:17 +02:00
Florian Bruhin
c33f0c3512 Use @cmdutils.argument for completions 2016-05-18 06:55:17 +02:00
Florian Bruhin
3ab40bbc23 Clear globals correctly for all cmdutils tests
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
2016-05-18 06:55:17 +02:00
Florian Bruhin
c14db202d6 Use @cmdutils.argument to hide arguments 2016-05-18 06:55:17 +02:00
Florian Bruhin
2370793f38 Make win_id/count mutually exclusive for ArgInfo 2016-05-18 06:55:17 +02:00
Florian Bruhin
35135c4b0d Use @cmdutils.argument for win_id/count 2016-05-18 06:55:17 +02:00
Florian Bruhin
04367851c3 Refactor how cmdutils.ArgInfo works
It's now a real class, and some other aspects about how it's handled
were cleaned up as well.
2016-05-18 06:55:17 +02:00
Florian Bruhin
9eeaeb95c3 Make sure @cmdutils.argument after @register fails 2016-05-18 06:55:17 +02:00
Florian Bruhin
3c586f34ff Add a @cmdutils.argument decorator
For now the only available keyword argument is 'flag' which customizes
the flag an argument will get.

See #637.
2016-05-18 06:55:17 +02:00
Liam BEGUIN
f689cca101 Added missing All group 2016-05-17 23:57:36 -04:00
Liam BEGUIN
ce0d23bd10 Added tests for the inputs group 2016-05-17 19:58:48 -04:00
Ryan Roden-Corrent
822d148713 Update key hint tests for new format.
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.
2016-05-17 07:04:53 -04:00
Ryan Roden-Corrent
3cd252ef82 Clean up html for keyhint text.
The \t was behaving the same as a space and the <b> was doing nothing.
2016-05-15 22:33:53 -04:00
Ryan Roden-Corrent
8eee5def5d Add unit tests for the keyhint widget.
- 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
2016-05-15 22:20:52 -04:00
Panagiotis Ktistakis
224c877fec Hide passwords in hovering URLs 2016-05-15 19:07:10 +03:00
Panagiotis Ktistakis
c88883fcb3 Decode URL in statusbar when hovering over it 2016-05-14 19:52:24 +03:00
Florian Bruhin
c64e5c9bd5 Get rid of the colorlog dependency
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.
2016-05-13 21:19:33 +02:00
Florian Bruhin
36da07c73b Fix lint 2016-05-10 07:56:54 +02:00
Florian Bruhin
5eff35ba30 cmdutils.register: annotation -> arg for flags
Instead of using a 'flag' key in the annotation dict, we now use a flags
argument to @cmdutils.register which is a {argument: flag} dict.

See #637.
2016-05-10 07:35:41 +02:00
Florian Bruhin
49fb981e7f Add test for completion count in cmdutils.register 2016-05-10 07:12:50 +02:00
Florian Bruhin
9ca5acd546 Add tests for flags with @cmdutils.register 2016-05-10 07:00:10 +02:00
Florian Bruhin
b17ecd1376 Add tests for cmdutils.register/star_args_optional 2016-05-10 06:41:42 +02:00
Florian Bruhin
a23aa1cc47 Fix broken supports_selection() test 2016-05-08 22:39:39 +02:00
Florian Bruhin
b9b6f357da Add utils.supports_selection() 2016-05-08 22:06:59 +02:00
Florian Bruhin
ddc1f803c0 Clean up assertion 2016-05-08 20:01:35 +02:00
Florian Bruhin
f49cc4e901 Only keep contain tests 2016-05-08 19:57:59 +02:00
Florian Bruhin
65ed878dcf Update copyright 2016-05-08 19:57:18 +02:00
Florian Bruhin
fdb28e4c71 Add test_sortfilter from #950 2016-05-08 19:56:41 +02:00
Florian Bruhin
f306ca9b53 Fix lint 2016-05-08 11:14:42 +02:00
Florian Bruhin
b4272975f2 Revert "Use lists instead of tuples"
This reverts commit eb5bfc1659.
2016-05-08 11:09:47 +02:00
Florian Bruhin
4403f02ac5 Fix HostBlocker.on_config_changed with no datadir 2016-05-07 23:35:30 +02:00
Florian Bruhin
6d1764e732 Clear blocked hosts on start correctly 2016-05-07 23:31:35 +02:00
Florian Bruhin
f6544786c1 dict 2016-05-07 22:41:22 +02:00
Florian Bruhin
2d8bde62a5 docstring 2016-05-07 22:39:53 +02:00
Florian Bruhin
9e64e5eab4 Check CommandError exception value 2016-05-07 22:39:09 +02:00
Florian Bruhin
f4f329714d Reformat dicts 2016-05-07 22:38:37 +02:00
Florian Bruhin
1a03388fb5 Fix docstrings 2016-05-07 22:28:06 +02:00
Florian Bruhin
eb5bfc1659 Use lists instead of tuples 2016-05-07 22:12:28 +02:00
Florian Bruhin
bc8d19f003 Fix typo 2016-05-07 22:09:43 +02:00
Florian Bruhin
2ae8ecff71 Use qapp fixture in all adblock tests 2016-05-07 22:08:55 +02:00
Florian Bruhin
7db6f52fa1 Merge branch 'test_adblock' of https://github.com/jcorentin/qutebrowser into jcorentin-test_adblock 2016-05-07 22:06:43 +02:00
Ryan Roden-Corrent
98508bdd26 Allow flexible whitespace in color strings.
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.
2016-05-03 23:15:39 -04:00
Florian Bruhin
48c7eee6f6 Release v0.6.2 2016-04-30 18:16:43 +02:00
Florian Bruhin
43d898aa63 Fix log tests 2016-04-30 17:45:45 +02:00
Florian Bruhin
2d5ffbfd02 Revert "Handle counts for special keys."
This reverts commit c881730fad.

This is just a temporary solution until we can properly fix this.

See #1464
2016-04-29 14:20:11 +02:00
Florian Bruhin
8b227f4ba4 Merge branch 'special_key_count' of https://github.com/rcorre/qutebrowser into rcorre-special_key_count 2016-04-28 22:22:23 +02:00
Florian Bruhin
076b486368 Merge branch 'issue-1412' of https://github.com/Kingdread/qutebrowser into Kingdread-issue-1412 2016-04-27 21:19:04 +02:00
Florian Bruhin
2a343cb3a1 Various code style improvements 2016-04-27 20:25:27 +02:00
Daniel Schadt
758fb94414 tests: add test for DiskCache with cache_dir=None 2016-04-27 00:04:02 +02:00
Florian Bruhin
ef91fa3821 Merge branch 'marks' of https://github.com/rcorre/qutebrowser into rcorre-marks 2016-04-21 20:05:41 +02:00
Ryan Roden-Corrent
c881730fad Handle counts for special keys.
Now 3<ctrl-o> will execute whatever <ctrl-o> is mapped to with count=3.
2016-04-19 23:39:02 -04:00
Florian Bruhin
6aaea2aa31 Fix HeaderDict with an empty value 2016-04-19 09:43:54 +02:00
Florian Bruhin
c5999443a1 Implement a HeaderDict config type
Supersedes #1132.
Fixes #1022.
2016-04-19 06:35:20 +02:00
Ryan Roden-Corrent
4b00a17d71 Fix MarkKeyParser crash when changing keyconfig.
Ensure MarkKeyParser implements on_keyconfig_changed, so it doesn't fail when
rebinding a key. It doesn't have keybindings, so the implementation is just
`pass`.

This also fixes a few flake8 style errors.
2016-04-17 21:04:08 -04:00
Florian Bruhin
c690e652dc Release v0.6.1 2016-04-10 21:25:32 +02:00
Florian Bruhin
1954ebd63c Fix test_last_window_session_none 2016-04-10 18:22:58 +02:00
Florian Bruhin
642dc46ba9 flake8: Add hacking 2016-04-08 07:35:53 +02:00
Florian Bruhin
00873fd000 Fix Proxy configtype test 2016-04-07 21:42:26 +02:00
Florian Bruhin
2f520f3b17 Rename test_editor.py to test_editor_unit.py 2016-04-05 19:49:01 +02:00
Florian Bruhin
c67edcf811 tests: Add v0.6.0 config to test_old_config 2016-04-04 18:16:31 +02:00
Florian Bruhin
19edea7343 Rename unit/misc/test_sessions.py to *_unit.py
Otherwise we get:

import file mismatch:
imported module 'test_sessions' has this __file__ attribute:
  /home/florian/proj/qutebrowser/git/tests/integration/features/test_sessions.py
which is not the same as the test file we want to collect:
  /home/florian/proj/qutebrowser/git/tests/unit/misc/test_sessions.py
HINT: remove __pycache__ / .pyc files and/or use a unique basename for your test file modules
2016-04-01 07:52:54 +02:00
Florian Bruhin
aad2407de1 Merge branch 'force-current-tab' of https://github.com/paretje/qutebrowser into paretje-force-current-tab 2016-04-01 06:13:08 +02:00
Kevin Velghe
0652637fbe Refactor unit tests for remove_blank_target 2016-04-01 01:32:27 +02:00
Florian Bruhin
89742beb4e pylint: useless-suppression in test_qt_javascript
When QtWebEngine is available, the suppression is useless.
2016-03-31 20:18:26 +02:00
Kevin Velghe
e90ad3d9c0 Complete coverage for webelem 2016-03-31 10:25:44 +02:00
Kevin Velghe
00f1e699d4 Add extra test to test_remove_blank_target 2016-03-30 23:46:02 +02:00
Kevin Velghe
dd4710d596 Fix test_remove_blank_target 2016-03-30 19:54:42 +02:00
Kevin Velghe
a432102be0 Add webelem tests for remove_blank_target 2016-03-30 19:08:37 +02:00
Florian Bruhin
5a5e8167dd Fix lint 2016-03-29 23:20:39 +02:00
Florian Bruhin
6c7e2492e9 Merge branch 'dirbrowser-issue-1334' of https://github.com/Kingdread/qutebrowser into Kingdread-dirbrowser-issue-1334 2016-03-29 22:38:04 +02:00
Florian Bruhin
fc7e75c355 Fix lint 2016-03-29 22:30:26 +02:00
Florian Bruhin
4067d38cb0 Add some tests for QtWebKit/Engine JS capabilities 2016-03-29 22:08:49 +02:00
Florian Bruhin
de5ecbf4e7 Fix lint 2016-03-29 21:10:29 +02:00
Florian Bruhin
f43cbed72f tests: Inherit HTTPPostStub from QObject
This way we can test the actual signals instead of calling
on_client_success by hand.
2016-03-29 19:22:28 +02:00
Florian Bruhin
25555682dc Merge branch 'master' of https://github.com/arsana7/qutebrowser into arsana7-master 2016-03-29 18:59:06 +02:00
Daniel Schadt
2db5b95552 tests: use "if not parent_elem"
Also add a new test for browsing the root directory
2016-03-29 12:36:43 +02:00
Florian Bruhin
f15fb16ad4 Fix small nitpick 2016-03-29 07:09:17 +02:00
Florian Bruhin
606471c4b6 Merge branch 'test_statusbar_url' of https://github.com/craftyguy/qutebrowser into craftyguy-test_statusbar_url 2016-03-29 07:07:45 +02:00
Clayton Craft
c811db5424 remove unused import 2016-03-28 15:31:28 -07:00
Clayton Craft
e0c0613db6 Added new test for simulating loading page and hover/unhover URL 2016-03-28 15:12:16 -07:00
Daniel Schadt
5e73a2ea37 dirbrowser: move parent dir logic to own function 2016-03-28 23:10:20 +02:00
Daniel Schadt
e97b10517f tests: use file_url for dirbrowser tests
Otherwise the tests will fail on windows.
2016-03-28 23:10:20 +02:00
Daniel Schadt
700756aa16 tests: add more cases for dirbrowser.is_root
The trailing slash might have an effect on the function result, so we
should have cases with/without the slash.
2016-03-28 23:08:54 +02:00
Clayton Craft
32304f36dd fix pylint failure 2016-03-25 16:35:49 -07:00
Florian Bruhin
387e35d3e5 Fix lint 2016-03-26 00:24:54 +01:00
Florian Bruhin
9edc5a665e Handle jinja's UndefinedError in jinja.render
We can get UndefinedError when a new function got added to the jinja
env (and gets called from a template) and the user did update the
on-disk templates but not restart qutebrowser yet.

In this case, let's show a special error page to the user and tell them
to do :report in the unlikely case it's actually a bug.

Fixes #1362.
See #1360.
2016-03-26 00:00:06 +01:00
Clayton Craft
4778ff6f9c Cleaned up url test and improved coveraged based on feedback 2016-03-25 15:56:39 -07:00
Florian Bruhin
86b12a302e Add a jinja.render helper
This simplifies some code and will make #1362 possible.
2016-03-25 14:29:30 +01:00
Clayton Craft
ff4e17190f Allow searching system-wide data path on Linux for userscripts 2016-03-24 13:22:00 -07:00
Clayton Craft
a78644a199 Implement statusbar.url test 2016-03-24 12:57:14 -07:00