Courses/Testing & Debugging

🧪 Testing & Debugging

doctest

Tests live inside your docstrings.

doctest scans docstrings for interactive examples and runs them as tests. Documentation and tests stay in sync.

def square(n):
    """
    >>> square(3)
    9
    """
    return n * n
main.py
Output
Press Run to execute.
Expected output
attempted=1 failed=0

Sign in to track your progress across lessons.