Skip to content

Instantly share code, notes, and snippets.

@hitsumabushi
Created June 24, 2015 11:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hitsumabushi/8496cee5decf22f39585 to your computer and use it in GitHub Desktop.
Save hitsumabushi/8496cee5decf22f39585 to your computer and use it in GitHub Desktop.
doctestでprint文を無視する場合の例
x = 0
def f():
""" 適当にTrueが返る
>>> sys.stdout.write("magic comment:"); f() # doctest:+ELLIPSIS
magic comment:...
True
"""
for s in range(0, 2):
print(s)
return True
print(x)
if __name__ == "__main__":
import doctest
import sys
doctest.testmod(optionflags=doctest.ELLIPSIS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment