Mercurial > hg > hg-git
changeset 763:0a6e3f9acb81
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.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Sun, 31 Aug 2014 06:27:46 -0700 (2014-08-31) |
parents | c68edf83bfbc |
children | 13a3513f8e67 |
files | tests/heredoctest.py |
diffstat | 1 files changed, 19 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
new file mode 100644 --- /dev/null +++ b/tests/heredoctest.py @@ -0,0 +1,19 @@ +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)