Testing with Pytest


A module called mymath with two functions: add and div.


examples/pytest/mymath.py
def add(x, y):
    """Adding two numbers

    >>> add(2, 3)
    5

    """
    return x + y

def div(x, y):
    """Dividing two numbers

    >>> div(8, 2)
    4
    >>> div(8, 0)
    Traceback (most recent call last):
    ...
    ZeroDivisionError: integer division or modulo by zero

    """
    return x / y