Karva (0.1.4)
A Python test framework, written in Rust.
About Karva
Karva aims to be an efficient alternative to pytest
and unittest
.
While we do not yet support all of pytest's features, we aim to gradually add support for pytest alternatives as we add features.
Getting started
Installation
Karva is available as karva
on PyPI.
Use karva directly with uvx
:
uvx karva test
uvx karva version
Or install karva with uv
, or pip
:
uv tool install karva@latest
uv add --dev karva
pip install karva
Usage
By default, Karva will respect your .gitignore
files when discovering tests in specified directories.
To run your tests, try any of the following:
karva test
karva test tests/
karva test tests/test_example.py
Example
Here is a small example usage
tests/test.py
def test_pass():
assert True
def test_fail():
assert False, "This test should fail"
def test_error():
raise ValueError("This is an error")
Running karva:
uv run karva test tests/test.py
Provides the following output:
fail[assertion-failed]
--> test_fail at tests/test.py:5
| File "tests/test.py", line 6, in test_fail
| assert False, "This test should fail"
error[value-error]
--> test_error at tests/test.py:9
| File "tests/test.py", line 10, in test_error
| raise ValueError("This is an error")
Passed tests: 1
Failed tests: 1
Errored tests: 1
Contributing
Contributions are welcome! See CONTRIBUTING.md for more information.