There are two separate test systems for Python:
Located in api/python/slint/tests/. These test the slint Python API directly.
cd api/python/slint && uv run pytest -s -vThis automatically builds the slint-python shared library via maturin if needed.
The Rust test driver (tests/driver/python/python.rs) processes .slint test cases from tests/cases/:
-
Compiles the
.slintfile usingOutputFormat::Python(viacompile_syntax_node+generator::generate). This goes through LLR lowering and generates a.pyfile. -
Runs the generated
.pyfile as a subprocess usinguv run. The subprocess loads theslintPython module, which re-compiles the.slintsource usingslint-interpreter(with full inlining enabled).
test-driver-python lives in the separate tests/ Cargo workspace, so it needs
--manifest-path tests/Cargo.toml when run from the repository root:
cargo test --manifest-path tests/Cargo.toml -p test-driver-python
# or with a filter:
cargo test --manifest-path tests/Cargo.toml -p test-driver-python -- test_nameThe slint-python shared library used by the Python subprocess is built by uv sync in api/python/slint/, not by cargo build. It's installed into a Python venv managed by uv.
To force a rebuild after code changes:
cd api/python/slint && uv sync --reinstall-package slint && cd -cargo build -p slint-python builds a separate artifact that is NOT used by the Python tests. The test driver's LazyLock<PYTHON_PATH> calls uv sync once per test run, but this may not detect source changes.
Issues can occur in two places:
-
Test driver process (compilation): the test driver compiles the
.slintsource withOutputFormat::Pythonand generates the.pyfile. To debug, modify compiler code and rebuild withcargo build --manifest-path tests/Cargo.toml -p test-driver-python. -
Python subprocess (runtime): the
slintPython module re-compiles the.slintsource viaslint-interpreterand executes it. To debug, modify compiler/runtime code AND rebuild slint-python (cd api/python/slint && uv sync --reinstall-package slint).
The subprocess's STDERR/STDOUT is captured and printed in the test output under STDERR: / STDOUT: headers.