MCPcopy
hub / github.com/mitmproxy/mitmproxy / test_simple

Function test_simple

test/mitmproxy/test_command.py:551–577  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

549
550
551def test_simple():
552 with taddons.context() as tctx:
553 c = command.CommandManager(tctx.master)
554 a = TAddon()
555 c.add("one.two", a.cmd1)
556 assert c.commands["one.two"].help == "cmd1 help"
557 assert c.execute("one.two foo") == "ret foo"
558 assert c.execute('one.two "foo"') == "ret foo"
559 assert c.execute("one.two 'foo bar'") == "ret foo bar"
560 assert c.call("one.two", "foo") == "ret foo"
561 with pytest.raises(exceptions.CommandError, match="Unknown"):
562 c.execute("nonexistent")
563 with pytest.raises(exceptions.CommandError, match="Invalid"):
564 c.execute("")
565 with pytest.raises(exceptions.CommandError, match="argument mismatch"):
566 c.execute("one.two too many args")
567 with pytest.raises(exceptions.CommandError, match="Unknown"):
568 c.call("nonexistent")
569 with pytest.raises(exceptions.CommandError, match="Unknown"):
570 c.execute("\\")
571
572 c.add("empty", a.empty)
573 c.execute("empty")
574
575 fp = io.StringIO()
576 c.dump(fp)
577 assert fp.getvalue()
578
579
580def test_typename():

Callers

nothing calls this directly

Calls 7

addMethod · 0.95
executeMethod · 0.95
callMethod · 0.95
dumpMethod · 0.95
contextMethod · 0.80
getvalueMethod · 0.80
TAddonClass · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…