stubs
The community/test/stubs
directory provides stub implementations of Talon APIs for use in tests. These stubs allow for isolated testing of Talon scripts without needing a full Talon installation. This directory is made available to tests by pytest's pythonpath configuration. The implementation of the stubs are mostly no-ops, but some functionality is implemented to allow for introspection and changing within tests. This is described in the top level README
.
The directory contains a subdirectory talon
which contains the primary Talon stubs. It contains stubs for various Talon modules and classes. These stubs are used in tests to simulate the Talon environment without needing a full Talon installation.
The talon
directory contains one subdirectory, experimental
, and two files: __init__.py
and grammar.py
.
The experimental
subdirectory contains stubs for experimental Talon features, and currently only includes textarea.py
, which provides type hints for the TextArea
related classes.
The __init__.py
file is the main stub file. It defines classes that mimic key Talon components such as actions
, Module
, Context
, ImgUI
, UI
, Settings
, Registry
, Resource
, and App
. These classes provide simplified implementations of their Talon counterparts, allowing tests to interact with them without relying on the actual Talon runtime. The Actions
class simulates the talon.actions
module, allowing tests to register and call actions. The Module
class simulates the talon.Module
class, providing stub implementations for list
, setting
, capture
, tag
and action_class
. The Context
class simulates the talon.Context
class, offering stub implementations of action_class
and capture
methods as well as a lists
property. The ImgUI
, UI
, Settings
, Registry
, Resource
, and App
classes provide stubs for their respective Talon counterparts, preventing crashes and enabling basic interactions during testing.
The grammar.py
file provides stub implementations of the Phrase
class, used as a type hint in the community code, and prevents tests from incorrectly identifying actual objects as the stub Phrase
type.