annotate tests/heredoctest.py @ 1108:aae2d15de6af

git_handler: store gpgsig header to maintain commit coherence
author Tony Tung <ttung@chanzuckerberg.com <mailto:ttung@chanzuckerberg.com>>
date Tue, 06 Feb 2018 17:04:24 -0800
parents 0a6e3f9acb81
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
762
0a6e3f9acb81 tests: add support for inline python
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
1 import sys
0a6e3f9acb81 tests: add support for inline python
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
2
0a6e3f9acb81 tests: add support for inline python
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
3 globalvars = {}
0a6e3f9acb81 tests: add support for inline python
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
4 localvars = {}
0a6e3f9acb81 tests: add support for inline python
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
5 lines = sys.stdin.readlines()
0a6e3f9acb81 tests: add support for inline python
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
6 while lines:
0a6e3f9acb81 tests: add support for inline python
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
7 l = lines.pop(0)
0a6e3f9acb81 tests: add support for inline python
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
8 if l.startswith('SALT'):
0a6e3f9acb81 tests: add support for inline python
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
9 print l[:-1]
0a6e3f9acb81 tests: add support for inline python
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
10 elif l.startswith('>>> '):
0a6e3f9acb81 tests: add support for inline python
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
11 snippet = l[4:]
0a6e3f9acb81 tests: add support for inline python
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
12 while lines and lines[0].startswith('... '):
0a6e3f9acb81 tests: add support for inline python
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
13 l = lines.pop(0)
0a6e3f9acb81 tests: add support for inline python
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
14 snippet += "\n" + l[4:]
0a6e3f9acb81 tests: add support for inline python
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
15 c = compile(snippet, '<heredoc>', 'single')
0a6e3f9acb81 tests: add support for inline python
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
16 try:
0a6e3f9acb81 tests: add support for inline python
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
17 exec c in globalvars, localvars
0a6e3f9acb81 tests: add support for inline python
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
18 except Exception, inst:
0a6e3f9acb81 tests: add support for inline python
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
19 print repr(inst)