All docs
Context·
classmethod
Context.testing
build a fake context for unit tests
Python
testing(**fields: Any) -> Context
Returns Context — a stub with only the named slots populated
Parameters#
| name | type | default | description |
|---|---|---|---|
**fields |
Any |
— | slot overrides — any of host, engine, project, entity, selection, ui, viewer, panel, events |
Example#
Python
ctx = Context.testing(project=my_project)
# override several slots at once
ctx = Context.testing(project=fake_project, ui=fake_ui)
Notes#
A classmethod on Context. Only the named slots are populated; every other slot stays None. Use it
to drive a command or action handler in a unit test without a running application.
See also#
Guides: Commands & actions
By LSD Team · Last updated Jul 17, 2026
Ask on Discord
View as Markdown