/ Published in: Python
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
def methodToTest(x): """ >>> methodToTest(2) 1 >>> methodToTest(0) Traceback (most recent call last): ... ZeroDivisionError: ... >>> range(10) [0, 1, 2, ..., 9] """ return 2/x if __name__ == "__main__": import doctest doctest.testmod(optionflags=doctest.ELLIPSIS+doctest.NORMALIZE_WHITESPACE) #doctest.testfile("example.txt")