##// END OF EJS Templates
heredoctest: use the same dict for local/global contexts as in doctest...
Yuya Nishihara -
r22564:9599e861 default
parent child Browse files
Show More
@@ -1,7 +1,6 b''
1 import sys
1 import sys
2
2
3 globalvars = {}
3 globalvars = {}
4 localvars = {}
5 lines = sys.stdin.readlines()
4 lines = sys.stdin.readlines()
6 while lines:
5 while lines:
7 l = lines.pop(0)
6 l = lines.pop(0)
@@ -14,6 +13,6 b' while lines:'
14 snippet += "\n" + l[4:]
13 snippet += "\n" + l[4:]
15 c = compile(snippet, '<heredoc>', 'single')
14 c = compile(snippet, '<heredoc>', 'single')
16 try:
15 try:
17 exec c in globalvars, localvars
16 exec c in globalvars
18 except Exception, inst:
17 except Exception, inst:
19 print repr(inst)
18 print repr(inst)
@@ -37,6 +37,11 b' Doctest commands:'
37 z
37 z
38 >>> print
38 >>> print
39
39
40 >>> foo = 'global name'
41 >>> def func():
42 ... print foo, 'should be visible in func()'
43 >>> func()
44 global name should be visible in func()
40
45
41 Regular expressions:
46 Regular expressions:
42
47
General Comments 0
You need to be logged in to leave comments. Login now