class MethodicalTests(TestCase): (source)
Tests for MethodicalMachine
.
Method | test_bad |
Calling any input method that lacks a transition for the machine's current state raises an informative NoTransition . |
Method | test_collect |
Outputs can be combined with the "collector" argument to "upon". |
Method | test_default |
It is possible to write a transition with no outputs |
Method | test_filter |
filterArgs() should not filter the `args` parameter if outputSpec accepts `*args`. |
Method | test_get |
Type annotations should be included in the set of |
Method | test_input |
The wrapped input function must have an empty body. |
Method | test_input |
All the argument lists of the outputs for a given input must match; if one does not the call to upon will raise a TypeError. |
Method | test_input |
If an input takes an argument, it will pass that along to its output. |
Method | test_machine |
MethodicalMachine is an implementation detail. If you attempt to access it on an instance of your class, you will get an exception. However, since tools may need to access it for the purposes of, for example, visualization, you may access it on the class itself. |
Method | test_method |
Input methods preserve their declared names. |
Method | test_multiple |
A MethodicalMachine can only have one initial state. |
Method | test_multiple |
Two machines may co-exist happily on the same instance; they don't interfere with each other. |
Method | test_multiple |
A MethodicalMachine can only have one transition per start/event pair. |
Method | test_one |
MethodicalMachine provides a way for you to declare a state machine with inputs, outputs, and states as methods. When you have declared an input, an output, and a state, calling the input method in that state will produce the specified output. |
Method | test_outputs |
One of the benefits of using a state machine is that your output method implementations don't need to take invalid state transitions into account - the methods simply won't be called. This property would be broken if client code called output methods directly, so output methods are not directly visible under their names. |
Method | test_output |
Inputs pass arguments that output will accept. |
Method | test_restore |
MethodicalMachine.unserializer decorates a function that becomes a machine-state unserializer; its return value is mapped to the serialized parameter to state, and the MethodicalMachine associated with that instance's state is updated to that state. |
Method | test_save |
MethodicalMachine.serializer is a decorator that modifies its decoratee's signature to take a "state" object as its first argument, which is the "serialized" argument to the MethodicalMachine.state decorator. |
Method | test_state |
It is possible to write a self-loop by omitting "enter" |
Calling any input method that lacks a transition for the machine's current state raises an informative NoTransition
.
All the argument lists of the outputs for a given input must match; if one does not the call to upon will raise a TypeError.
MethodicalMachine
is an implementation detail. If you attempt to access it on an instance of your class, you will get an exception. However, since tools may need to access it for the purposes of, for example, visualization, you may access it on the class itself.
MethodicalMachine
provides a way for you to declare a state machine with inputs, outputs, and states as methods. When you have declared an input, an output, and a state, calling the input method in that state will produce the specified output.
One of the benefits of using a state machine is that your output method implementations don't need to take invalid state transitions into account - the methods simply won't be called. This property would be broken if client code called output methods directly, so output methods are not directly visible under their names.
MethodicalMachine.unserializer
decorates a function that becomes a machine-state unserializer; its return value is mapped to the serialized parameter to state, and the MethodicalMachine
associated with that instance's state is updated to that state.
MethodicalMachine.serializer
is a decorator that modifies its decoratee's signature to take a "state" object as its first argument, which is the "serialized" argument to the MethodicalMachine.state
decorator.