Testing
Install Test Dependencies
pip install briefcase-ai[dev]The dev extra installs pytest, pytest-mock, pytest-asyncio, pytest-subtests, black, flake8, and mypy.
Build the Native Extension First
The Python facade tests mock briefcase._native, while the native binding tests run against the real extension. Build it before running either suite:
maturin developRun the Test Suites
pytest tests/ # Python facade (mocks briefcase._native)pytest bindings/python/tests/ # native binding tests (real extension)python scripts/check_imports.py # smoke-test that every submodule importsThe facade suite and the native binding suite mock the extension differently, so run them in separate processes (do not collect both in one pytest invocation).
Run Rust Tests
cargo test -p briefcase-core --lockedRun Specific Tests
cargo test -p briefcase-core test_snapshot_creationpytest tests/ -k "capture"Continuous Integration
CI builds the native extension with maturin and runs the Python suites across Python 3.9, 3.10, 3.11, 3.12, and 3.13. A separate job builds, tests, and clippy-lints the Rust core.
Writing Tests
Rust
#[cfg(test)]mod tests { use super::*; use serde_json::json;
#[test] fn test_snapshot_creation() { let snapshot = DecisionSnapshot::new("ai_function") .add_input(Input::new("query", json!("hello"), "string")) .add_output(Output::new("response", json!("hi"), "string")); assert_eq!(snapshot.function_name, "ai_function"); }}Python
The facade test suite mocks briefcase._native, so import the public API and assert on behavior:
from briefcase import capture
def test_capture_returns_result(): @capture() def my_fn(x): return x * 2
assert my_fn(5) == 10