diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2017-12-19 18:01:39 +1300 |
---|---|---|
committer | Aldo Cortesi <aldo@corte.si> | 2017-12-20 08:21:48 +1300 |
commit | 3341edc9fa8e70306e91cf911e4b2b19ef60ba84 (patch) | |
tree | 6130b0c1053895f7eea6a1cc07252dbaee94b157 /test/mitmproxy/test_types.py | |
parent | d98fc4f03a88751944c0ae08ee2ac3e743f92952 (diff) | |
download | mitmproxy-3341edc9fa8e70306e91cf911e4b2b19ef60ba84.tar.gz mitmproxy-3341edc9fa8e70306e91cf911e4b2b19ef60ba84.tar.bz2 mitmproxy-3341edc9fa8e70306e91cf911e4b2b19ef60ba84.zip |
commander: highlight commands
Step 1 of the fancification of commander.
Diffstat (limited to 'test/mitmproxy/test_types.py')
-rw-r--r-- | test/mitmproxy/test_types.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/test/mitmproxy/test_types.py b/test/mitmproxy/test_types.py index 46e23ff3..29e86203 100644 --- a/test/mitmproxy/test_types.py +++ b/test/mitmproxy/test_types.py @@ -136,6 +136,8 @@ def test_strseq(): class DummyConsole: @command.command("view.resolve") def resolve(self, spec: str) -> typing.Sequence[flow.Flow]: + if spec == "err": + raise mitmproxy.exceptions.CommandError() n = int(spec) return [tflow.tflow(resp=True)] * n @@ -157,9 +159,11 @@ def test_flow(): assert b.is_valid(tctx.master.commands, flow.Flow, tflow.tflow()) is True assert b.is_valid(tctx.master.commands, flow.Flow, "xx") is False with pytest.raises(mitmproxy.exceptions.TypeError): - assert b.parse(tctx.master.commands, flow.Flow, "0") + b.parse(tctx.master.commands, flow.Flow, "0") with pytest.raises(mitmproxy.exceptions.TypeError): - assert b.parse(tctx.master.commands, flow.Flow, "2") + b.parse(tctx.master.commands, flow.Flow, "2") + with pytest.raises(mitmproxy.exceptions.TypeError): + b.parse(tctx.master.commands, flow.Flow, "err") def test_flows(): @@ -175,6 +179,8 @@ def test_flows(): assert len(b.parse(tctx.master.commands, typing.Sequence[flow.Flow], "0")) == 0 assert len(b.parse(tctx.master.commands, typing.Sequence[flow.Flow], "1")) == 1 assert len(b.parse(tctx.master.commands, typing.Sequence[flow.Flow], "2")) == 2 + with pytest.raises(mitmproxy.exceptions.TypeError): + b.parse(tctx.master.commands, typing.Sequence[flow.Flow], "err") def test_data(): |