summaryrefslogtreecommitdiff
path: root/tests/heredoctest.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/heredoctest.py')
-rw-r--r--tests/heredoctest.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/heredoctest.py b/tests/heredoctest.py
new file mode 100644
index 0000000..7508c18
--- /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)