tests/heredoctest.py
author Augie Fackler <augie@google.com>
Fri, 11 Mar 2016 11:24:50 -0500
changeset 28483 6f38ec428a19
parent 27297 4179d054b3e9
child 29485 6a98f9408a50
permissions -rw-r--r--
httppeer: do less splitting on httpheader value We only care about the first value split off, so only split off the first value.

from __future__ import absolute_import

import sys

globalvars = {}
lines = sys.stdin.readlines()
while lines:
    l = lines.pop(0)
    if l.startswith('SALT'):
        print(l[:-1])
    elif l.startswith('>>> '):
        snippet = l[4:]
        while lines and lines[0].startswith('... '):
            l = lines.pop(0)
            snippet += l[4:]
        c = compile(snippet, '<heredoc>', 'single')
        try:
            exec(c, globalvars)
        except Exception as inst:
            print(repr(inst))