Skip to content

Quick Start

1. Write a test

Add @test to any function in your source code:

# math_utils.py
from inline_tests import test

def add(a, b):
    return a + b

@test
def addition_works():
    assert add(2, 2) == 4
    assert add(-1, 1) == 0

2. Run it

itest

That's it. The test runs. Your normal code stays the same.

3. Mix with regular tests

inline-tests is additive. Your test_*.py files still work:

# Run inline tests
itest

# Run regular pytest tests
pytest

# Run both
itest && pytest

Alias suggestion

Add to your shell config:

alias t="itest && pytest"

Next steps