aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorHenrique <typoon@gmail.com>2019-11-16 09:16:50 -0500
committerHenrique <typoon@gmail.com>2019-11-16 09:16:50 -0500
commit79caf3a458a221763cbf389f8ac5cccd9221e290 (patch)
tree5af087b3b4b5b7a661015b02c1bcf247ebeb57f9 /test
parenta244ece0e55db1ac4895e3ee20b138ab3c617ca2 (diff)
downloadmitmproxy-79caf3a458a221763cbf389f8ac5cccd9221e290.tar.gz
mitmproxy-79caf3a458a221763cbf389f8ac5cccd9221e290.tar.bz2
mitmproxy-79caf3a458a221763cbf389f8ac5cccd9221e290.zip
Fixing issues pointed during PR review
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/test_command.py14
-rw-r--r--test/mitmproxy/tools/console/test_commander.py18
-rw-r--r--test/mitmproxy/tools/console/test_defaultkeys.py3
3 files changed, 25 insertions, 10 deletions
diff --git a/test/mitmproxy/test_command.py b/test/mitmproxy/test_command.py
index ae4c400c..f5a641a8 100644
--- a/test/mitmproxy/test_command.py
+++ b/test/mitmproxy/test_command.py
@@ -92,8 +92,6 @@ class TestCommand:
c = command.Command(cm, "varargs", a.varargs)
assert c.signature_help() == "varargs str *str -> [str]"
assert c.call(["one", "two", "three"]) == ["two", "three"]
- with pytest.raises(exceptions.CommandError):
- c.call(["one", "two", 3])
def test_call(self):
with taddons.context() as tctx:
@@ -333,18 +331,20 @@ class TestCommand:
[],
],
[
- " spaces_at_the_begining_are_stripped",
+ " spaces_at_the_begining_are_not_stripped",
[
- command.ParseResult(value = "spaces_at_the_begining_are_stripped", type = mitmproxy.types.Cmd, valid = False),
+ command.ParseResult(value = " ", type = mitmproxy.types.Unknown, valid = False),
+ command.ParseResult(value = "spaces_at_the_begining_are_not_stripped", type = mitmproxy.types.Cmd, valid = False),
],
[],
],
[
- " spaces_at_the_begining_are_stripped but_not_at_the_end ",
+ " spaces_at_the_begining_are_not_stripped neither_at_the_end ",
[
- command.ParseResult(value = "spaces_at_the_begining_are_stripped", type = mitmproxy.types.Cmd, valid = False),
+ command.ParseResult(value = " ", type = mitmproxy.types.Unknown, valid = False),
+ command.ParseResult(value = "spaces_at_the_begining_are_not_stripped", type = mitmproxy.types.Cmd, valid = False),
command.ParseResult(value = " ", type = mitmproxy.types.Unknown, valid = False),
- command.ParseResult(value = "but_not_at_the_end", type = mitmproxy.types.Unknown, valid = False),
+ command.ParseResult(value = "neither_at_the_end", type = mitmproxy.types.Unknown, valid = False),
command.ParseResult(value = " ", type = mitmproxy.types.Unknown, valid = False),
],
[],
diff --git a/test/mitmproxy/tools/console/test_commander.py b/test/mitmproxy/tools/console/test_commander.py
index 798ca5fe..8c3e6839 100644
--- a/test/mitmproxy/tools/console/test_commander.py
+++ b/test/mitmproxy/tools/console/test_commander.py
@@ -165,3 +165,21 @@ class TestCommandBuffer:
cb = commander.CommandBuffer(tctx.master)
cb.text = "foo"
assert cb.render()
+
+ cb.text = 'set view_filter=~bq test'
+ ret = cb.render()
+ assert ret[0] == ('commander_command', 'set')
+ assert ret[1] == ('commander_invalid', ' ')
+ assert ret[2] == ('text', 'view_filter=~bq')
+ assert ret[3] == ('commander_invalid', ' ')
+ assert ret[4] == ('commander_invalid', 'test')
+
+ cb.text = "set"
+ ret = cb.render()
+ assert ret[0] == ('commander_command', 'set')
+ assert ret[1] == ('text', ' ')
+ assert ret[2] == ('commander_hint', 'str ')
+
+ # import pdb
+ # pdb.set_trace()
+ # print('x')
diff --git a/test/mitmproxy/tools/console/test_defaultkeys.py b/test/mitmproxy/tools/console/test_defaultkeys.py
index 7e8df6b6..40e536b0 100644
--- a/test/mitmproxy/tools/console/test_defaultkeys.py
+++ b/test/mitmproxy/tools/console/test_defaultkeys.py
@@ -29,7 +29,4 @@ async def test_commands_exist():
try:
cmd_obj.prepare_args(args)
except Exception as e:
-
- import pdb
- pdb.set_trace()
raise ValueError("Invalid command: {}".format(binding.command)) from e