如何讓我的(Python 2.7)代碼知道它是否在doctest中運行? 的情況如下:我有一個功能,print()小號一些輸出傳遞作爲參數文件描述符,這樣的事情: from __future__ import print_function
def printing_func(inarg, file=sys.stdout):
# (do some stuff...)
prin
假設我有以下代碼: def foo(s):
"""A dummy function foo. For example:
>>> a = '''This is a test string line 1
This is a test string line 2
This is a test string line 3'''
>>> foo(a)
This is a test st