mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-26 10:16:27 +00:00
parent
449b8b383d
commit
58ff51da10
@ -236,7 +236,10 @@ class CommandManager(mitmproxy.types._CommandBase):
|
|||||||
"""
|
"""
|
||||||
Execute a command string. May raise CommandError.
|
Execute a command string. May raise CommandError.
|
||||||
"""
|
"""
|
||||||
parts = list(lexer(cmdstr))
|
try:
|
||||||
|
parts = list(lexer(cmdstr))
|
||||||
|
except ValueError as e:
|
||||||
|
raise exceptions.CommandError("Command error: %s" % e)
|
||||||
if not len(parts) >= 1:
|
if not len(parts) >= 1:
|
||||||
raise exceptions.CommandError("Invalid command: %s" % cmdstr)
|
raise exceptions.CommandError("Invalid command: %s" % cmdstr)
|
||||||
return self.call_strings(parts[0], parts[1:])
|
return self.call_strings(parts[0], parts[1:])
|
||||||
|
@ -281,6 +281,8 @@ def test_simple():
|
|||||||
c.execute("one.two too many args")
|
c.execute("one.two too many args")
|
||||||
with pytest.raises(exceptions.CommandError, match="Unknown"):
|
with pytest.raises(exceptions.CommandError, match="Unknown"):
|
||||||
c.call("nonexistent")
|
c.call("nonexistent")
|
||||||
|
with pytest.raises(exceptions.CommandError, match="No escaped"):
|
||||||
|
c.execute("\\")
|
||||||
|
|
||||||
c.add("empty", a.empty)
|
c.add("empty", a.empty)
|
||||||
c.execute("empty")
|
c.execute("empty")
|
||||||
|
Loading…
Reference in New Issue
Block a user