Tutorial
This tutorial will walk you through the basics of using Karva.
Getting started
We will first create a new project using uv.
| Bash |
|---|
| uv init --lib .
mkdir tests
|
This will give us a project that looks like this:
| Text Only |
|---|
| .
├── pyproject.toml
├── README.md
├── src
│ └── karva_test
│ ├── __init__.py
│ └── py.typed
└── tests
|
| src/calculator/__init__.py |
|---|
| class Calculator:
def add(self, a: int, b: int) -> int:
return a + b
|
| tests/test_add.py |
|---|
| from calculator import Calculator
def test_add():
calculator = Calculator()
assert calculator.add(1, 2) == 3
|
Then, we'll add karva to our project.
We can then run our tests with uv run karva test.