XState for Python
Project description
XState for Python
XState for Python - work in progress!
How to use
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 again
More advanced examples in the "examples" folder
Testing
- Run
python3.7 -m venv .venv
to create a virtual environment - Run
source .venv/bin/activate
to go into that virtual environment - Run
pip install -r requirements_dev.txt
to install all of the dependencies inrequirements.txt
(which includespytest
) - Run
npm i @scion-scxml/test-framework
to download scxml files - Run
pytest
to run the tests! 👩🔬
SCXML
SCXML tests are ran from the SCION Test Framework module.
Related Projects
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
xstate-0.0.1.tar.gz
(9.1 kB
view hashes)
Built Distribution
xstate-0.0.1-py2-none-any.whl
(12.4 kB
view hashes)