Commit Graph

54 Commits

Author SHA1 Message Date
Florian Bruhin
19628d0ae9 Move cmdutils.cmd_dict to objects.commands 2018-11-29 14:18:11 +01:00
Florian Bruhin
14fe7f9b0b pass fixup 2018-11-28 12:58:48 +01:00
Florian Bruhin
2453134011 Remove unnecessary pass statements 2018-11-28 12:51:53 +01:00
Florian Bruhin
3b8964183e Use caplog.messages 2018-10-24 10:57:17 +02:00
Florian Bruhin
6f028e9ad0 Update copyright years 2018-02-05 12:19:50 +01:00
Ryan Farley
5ed8019115 update flake8 and flake8-deprecated
Updated requirements and adjusted the configuration in `.flake8`; other
files have been modified where the lack of per-file auto-ignore caused
problems, where putty's `# flake8: disable=` syntax could be replaced
with a simpler `noqa`, or where pylint directives already suppressed the
same error.
2017-11-26 00:16:14 -06:00
Florian Bruhin
f6cc6677dd Remove hiding of commands
This was often confusing for people - let's instead just hide commands which are
not available in normal mode.
2017-11-13 09:02:16 +01:00
Gyorgy Orban
98c6b49cde use enum module instead or usertypes.enum
Remove the usertypes.enum from the source and use
the standard enum module instead.
Enum start number is available since python 3.5
2017-11-02 18:56:11 +01:00
Florian Bruhin
505321c336 Drop support for Python 3.4
See #2742
2017-09-18 23:01:17 +02:00
Florian Bruhin
22b0f2fd24 Various simple test updates for new config
test_cache
test_cookies
test_webkitelem
test_cmdutils
test_runners
test_completionwidget
test_messageview
test_editor
test_miscwidgets
test_sessions
test_urlutils
test_utils
test_prompt
statusbar/test_*
test_cmdhistory
test_tabwidget
test_tab
test_downloads
test_networkmanager
2017-07-04 15:08:04 +02:00
Florian Bruhin
ac78039171 Use aliases for :w and :q 2017-07-04 15:08:03 +02:00
Florian Bruhin
0f3a17ae88 Fix raw string prefix 2017-05-23 10:09:06 +02:00
Florian Bruhin
ea2fbc427a tests: Use match= for pytest.raises 2017-05-23 09:36:00 +02:00
Florian Bruhin
822623f2ed Finally update copyrights... 2017-05-09 21:37:03 +02:00
Florian Bruhin
b1a95a3930 Add automatic backend selection in earlyinit 2017-02-05 17:09:04 +01:00
Florian Bruhin
de50f30b9b Replace all GitHub links 2017-02-05 00:13:11 +01:00
Florian Bruhin
552e0551af Revert zero counts
This initially seemed like a nice feature, but it means 0 can't be bound
as a separate key anymore, and 0<Esc> gives weird error messages...

Reverts #1953.
Fixes #2032.
2016-11-23 08:37:29 +01:00
Florian Bruhin
6b76d5defa Whitespace changes 2016-09-30 17:54:23 +02:00
Florian Bruhin
822c100f52 Make 0 a usable count for :tab-focus
Fixes #1768
2016-09-30 08:33:16 +02:00
Florian Bruhin
d0d3245d48 Remove extra blank line 2016-09-15 17:19:53 +02:00
Daniel Schadt
eabfdb3c16 tests: make sure the type error is the one we want 2016-09-15 16:42:02 +02:00
Daniel Schadt
b6d9d3f955 fix tests for new "default required" policy
This test had a keyword only parameter without a default, which is now
disallowed. This caused the test to fail.
2016-09-15 15:46:26 +02:00
Daniel Schadt
0ef5d338bd make sure keyword-only arguments have a default
Fixes #1872.

This prevents inspect.Parameter.empty from slipping through to the
command.
2016-09-15 15:44:33 +02:00
Florian Bruhin
8823ed2821 Improve cmdutils tests
This would have caught 12061b8bb1.
2016-08-25 22:16:25 +02:00
Florian Bruhin
943dc564b2 Fix choices validation with unannotated args
Something like:

    @cmdutils.argument('foo', choices=['one', 'two'])
    def func(foo):
        # ...

didn't actually validate the foo argument, since the inferred type of
the argument is None, and that skipped all conversion (and thus
validation).

Fixes #1871
See #1885

This is a reworked version of 12061b8bb1
which lets special parameters (count/win_id/flags) through correctly.
2016-08-25 22:16:25 +02:00
Florian Bruhin
445d287955 Revert "Fix choices validation with unannotated args"
This reverts commit 12061b8bb1.
2016-08-23 23:34:02 +02:00
Florian Bruhin
12061b8bb1 Fix choices validation with unannotated args
Something like:

    @cmdutils.argument('foo', choices=['one', 'two'])
    def func(foo):
        # ...

didn't actually validate the foo argument, since the inferred type of
the argument is None, and that skipped all conversion (and thus
validation).

Fixes #1871
See #1885
2016-08-23 22:01:21 +02:00
Florian Bruhin
a24391d40d Fix lint 2016-08-10 09:20:30 +02:00
Florian Bruhin
f0133624bf Add some tests for -OO logging 2016-08-10 09:05:04 +02:00
Ryan Roden-Corrent
c792ffda67 Remove Command.completion.
Command completion types are now identified by ArgInfo, so just use
that directly and cut out the middle-man. This shouldn't change any
completion behavior.

Adds a test for get_pos_arg_info to test_cmdutils.

Modifies test_completer to test the use of get_pos_arg_info. Instead of
using FakeCommand, real Command objects are used, to validate that the
Completer works with the real Command interface. This also cleans out
some test cases that were testing things already covered by other cases.
2016-08-06 11:59:04 -04:00
Marshall Lochbaum
c19e1947f8 Remove tests for cmdutils.arg_or_count (fixes #1735 with previous commits) 2016-08-02 12:02:40 -04:00
Florian Bruhin
2649418c0b Fix lint 2016-07-10 17:04:26 +02:00
Florian Bruhin
d2ece6b542 Move Backend enum to usertypes
Otherwise we have a cyclic import
2016-07-10 17:04:26 +02:00
Florian Bruhin
34e39bed4e Add a test for cmd instance with wrong backend 2016-07-10 17:04:25 +02:00
Florian Bruhin
7859df74c4 Add tests for Command.run 2016-07-10 17:04:25 +02:00
Florian Bruhin
2136d00aa2 tests: Add a fake_args fixture 2016-07-10 17:04:25 +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
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
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