##// 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 1 import sys
2 2
3 3 globalvars = {}
4 localvars = {}
5 4 lines = sys.stdin.readlines()
6 5 while lines:
7 6 l = lines.pop(0)
@@ -14,6 +13,6 b' while lines:'
14 13 snippet += "\n" + l[4:]
15 14 c = compile(snippet, '<heredoc>', 'single')
16 15 try:
17 exec c in globalvars, localvars
16 exec c in globalvars
18 17 except Exception, inst:
19 18 print repr(inst)
@@ -37,6 +37,11 b' Doctest commands:'
37 37 z
38 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 46 Regular expressions:
42 47
General Comments 0
You need to be logged in to leave comments. Login now