aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2019-11-18 03:45:16 +0100
committerMaximilian Hils <git@maximilianhils.com>2019-11-18 03:45:16 +0100
commitf75a95acea6772457b25395b0fdd2c97bfebb936 (patch)
tree2a24ef0ea662353a3d1fca5e63804b67b8e09678 /test
parentcb723c53fab93dae67f68b4414a35c8bec7fc144 (diff)
downloadmitmproxy-f75a95acea6772457b25395b0fdd2c97bfebb936.tar.gz
mitmproxy-f75a95acea6772457b25395b0fdd2c97bfebb936.tar.bz2
mitmproxy-f75a95acea6772457b25395b0fdd2c97bfebb936.zip
fix vararg handling
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/test_types.py3
-rw-r--r--test/mitmproxy/tools/console/test_commander.py14
-rw-r--r--test/mitmproxy/tools/console/test_defaultkeys.py17
3 files changed, 19 insertions, 15 deletions
diff --git a/test/mitmproxy/test_types.py b/test/mitmproxy/test_types.py
index c8f7afde..2cd17d87 100644
--- a/test/mitmproxy/test_types.py
+++ b/test/mitmproxy/test_types.py
@@ -128,8 +128,7 @@ def test_arg():
with taddons.context() as tctx:
b = mitmproxy.types._ArgType()
assert b.completion(tctx.master.commands, mitmproxy.types.CmdArgs, "") == []
- with pytest.raises(mitmproxy.exceptions.TypeError):
- b.parse(tctx.master.commands, mitmproxy.types.CmdArgs, "foo")
+ assert b.parse(tctx.master.commands, mitmproxy.types.CmdArgs, "foo") == "foo"
assert b.is_valid(tctx.master.commands, mitmproxy.types.CmdArgs, 1) is False
diff --git a/test/mitmproxy/tools/console/test_commander.py b/test/mitmproxy/tools/console/test_commander.py
index 9a2ec102..ce789d30 100644
--- a/test/mitmproxy/tools/console/test_commander.py
+++ b/test/mitmproxy/tools/console/test_commander.py
@@ -25,7 +25,7 @@ class TestListCompleter:
for start, options, cycle in tests:
c = commander.ListCompleter(start, options)
for expected in cycle:
- assert c.cycle() == expected
+ assert c.cycle(True) == expected
class TestCommandEdit:
@@ -252,7 +252,7 @@ class TestCommandBuffer:
cb = commander.CommandBuffer(tctx.master)
cb.text = "foo bar"
cb.cursor = len(cb.text)
- cb.cycle_completion()
+ cb.cycle_completion(True)
ch = commander.CommandHistory(tctx.master, 30)
ce = commander.CommandEdit(tctx.master, "se", ch)
@@ -261,7 +261,7 @@ class TestCommandBuffer:
ret = ce.cbuf.render()
assert ret[0] == ('commander_command', 'set')
assert ret[1] == ('text', ' ')
- assert ret[2] == ('commander_hint', 'str ')
+ assert ret[2] == ('commander_hint', '*options ')
def test_render(self):
with taddons.context() as tctx:
@@ -272,13 +272,13 @@ class TestCommandBuffer:
cb.text = 'set view_filter=~bq test'
ret = cb.render()
assert ret[0] == ('commander_command', 'set')
- assert ret[1] == ('commander_invalid', ' ')
+ assert ret[1] == ('text', ' ')
assert ret[2] == ('text', 'view_filter=~bq')
- assert ret[3] == ('commander_invalid', ' ')
- assert ret[4] == ('commander_invalid', 'test')
+ assert ret[3] == ('text', ' ')
+ assert ret[4] == ('text', 'test')
cb.text = "set"
ret = cb.render()
assert ret[0] == ('commander_command', 'set')
assert ret[1] == ('text', ' ')
- assert ret[2] == ('commander_hint', 'str ')
+ assert ret[2] == ('commander_hint', '*options ')
diff --git a/test/mitmproxy/tools/console/test_defaultkeys.py b/test/mitmproxy/tools/console/test_defaultkeys.py
index 9c79525b..58a0a585 100644
--- a/test/mitmproxy/tools/console/test_defaultkeys.py
+++ b/test/mitmproxy/tools/console/test_defaultkeys.py
@@ -1,10 +1,12 @@
+import pytest
+
+import mitmproxy.types
+from mitmproxy import command
+from mitmproxy import ctx
from mitmproxy.test.tflow import tflow
from mitmproxy.tools.console import defaultkeys
from mitmproxy.tools.console import keymap
from mitmproxy.tools.console import master
-from mitmproxy import command
-from mitmproxy import ctx
-import pytest
@pytest.mark.asyncio
@@ -18,10 +20,13 @@ async def test_commands_exist():
await m.load_flow(tflow())
for binding in km.bindings:
- results = command_manager.parse_partial(binding.command.strip())
+ parsed, _ = command_manager.parse_partial(binding.command.strip())
- cmd = results[0][0].value
- args = [a.value for a in results[0][1:]]
+ cmd = parsed[0].value
+ args = [
+ a.value for a in parsed[1:]
+ if a.type != mitmproxy.types.Space
+ ]
assert cmd in m.commands.commands