A Python test framework, written in Rust.
We'd love for you to try Karva! It's currently in alpha, and your feedback helps shape the project. Get started or join us on Discord.
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.
Karva is available as karva on PyPI.
Use karva directly with uvx:
uvx karva test
uvx karva versionOr install karva with uv, or pip:
# With uv.
uv tool install karva@latest
# Add karva to your project.
uv add --dev karva
# With pip.
pip install karvaBy default, Karva will respect your .gitignore files when discovering tests in specified directories.
To run your tests, try any of the following:
# Run all tests.
karva test
# Run tests in a specific directory.
karva test tests/
# Run tests in a specific file.
karva test tests/test_example.pyHere is a small example of using karva, as you can see it works just like pytest.
def test_pass():
assert True
def test_fail():
assert False, "This test should fail"Running karva:
uv run karva test tests/Provides the following output:
test tests.test::test_pass ... ok
test tests.test::test_fail ... FAILED
diagnostics:
error[test-failure]: Test `test_fail` failed
--> tests/test.py:5:5
|
5 | def test_fail():
| ^^^^^^^^^
6 | assert False, "This test should fail"
|
info: Test failed here
--> tests/test.py:6:5
|
5 | def test_fail():
6 | assert False, "This test should fail"
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
info: Error message: This test should fail
test result: FAILED. 1 passed; 1 failed; 0 skipped; finished in 8ms
Contributions are welcome! See CONTRIBUTING.md for more information.
You can also join us on Discord