XState for Python - work in progress!
from xstate import Machine
lights = Machine(
{
"id": "lights",
"initial": "green",
"states": {
"green": {"on": {"TIMER": "yellow"},},
"yellow": {"on": {"TIMER": "red"}},
"red": {"on": {"TIMER": "green"}},
},
}
)
state = lights.initial_state # state.value is green
state = lights.transition(state, "TIMER") # state.value is yellow
state = lights.transition(state, "TIMER") # state.value is red
state = lights.transition(state, "TIMER") # state.value is green again
More advanced examples in the "examples" folder
You can set up your development environment in two different ways.
Prerequisites
Steps
poetry run pytest --cov
to run the tests! 👩🔬 (or run the Run tests
task via VS Code or using VS Code Test explorer where you can debug as well)Prerequisites
poetry
for package and dependency managementSteps
poetry install
to create a virtual environmentgit submodule update --init
poetry run pytest --cov
to run the tests! 👩🔬 (or run the Run tests
task via VS Code or using VS Code Test explorer where you can debug as well)SCXML tests are ran from the SCION Test Framework module.