doctest
Tests written as interactive examples inside docstrings.
Easy
def square(x):
"""
>>> square(4)
16
"""
return x * x
Run with python -m doctest file.py -v.
Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.
Discussion (0)
Sign in or join free to ask questions and discuss this topic.