Example #1
0
 def execute(self, cmdstr: str) -> typing.Any:
     """
     Execute a command string. May raise CommandError.
     """
     parts, _ = self.parse_partial(cmdstr)
     if not parts:
         raise exceptions.CommandError(f"Invalid command: {cmdstr!r}")
     command_name, *args = [
         unquote(part.value) for part in parts
         if part.type != mitmproxy.types.Space
     ]
     return self.call_strings(command_name, args)
Example #2
0
def test_quote_unquote_cycle(s):
    assert command_lexer.unquote(command_lexer.quote(s)) == s
Example #3
0
def test_unquote_never_fails(s):
    command_lexer.unquote(s)
Example #4
0
def test_quote_unquote_cycle(s):
    assert command_lexer.unquote(command_lexer.quote(s)).replace(r"\x22",
                                                                 '"') == s