Skip to content
Snippets Groups Projects
Commit 0a6e3f9a authored by Siddharth Agarwal's avatar Siddharth Agarwal
Browse files

tests: add support for inline python

An upcoming patch will include an inline python test. tests/heredoctest.py is
copied over from the Mercurial repository.
parent c68edf83
No related branches found
No related tags found
No related merge requests found
import sys
globalvars = {}
localvars = {}
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 += "\n" + l[4:]
c = compile(snippet, '<heredoc>', 'single')
try:
exec c in globalvars, localvars
except Exception, inst:
print repr(inst)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment