XState for Python - work in progress!
from xstate.machine 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 againMore advanced examples in the "examples" folder
- Run
python3.7 -m venv .venvto create a virtual environment - Run
source .venv/bin/activateto go into that virtual environment - Run
pip install -r requirements_dev.txtto install all of the dependencies inrequirements.txt(which includespytest) - Run
npm i @scion-scxml/test-frameworkto download scxml files - Run
pytestto run the tests! 👩🔬
SCXML tests are ran from the SCION Test Framework module.