On 10/18/2012 8:08 PM, David wrote:
Hello, how to add if...else... switch to doctest?
E.g. function outputs different value when global_var change.

"""
if (global_var == True):
function()
[1,2]
else:
function()
[1,2,3]
"""

doctests should/must be self contained. IE, you would have to set the 'global_var' in the doctext code itself.

>>> def function():
...   if global_var: return [1,2]
...   else: return [1,2,3]
>>> global_var = True
>>>function()
[1,2]
>>> global_var = False
>>> function()
[1,2,3]

--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to