Open markrwilliams opened 7 years ago
(Per @tomprince)
At dinner tonight, @markrwilliams and I came up with some ideas:
Then standard set-intersection tests can be used to decide if the right transitions have been exercised. You could merge the traces of multiple context managers to look at combined coverage, or you could use setUp/tearDown
to merge multiple test cases and check the results at the very end of the test class.
class Foo(object):
m = MethodicalMachine()
...
f = Foo()
with gather_transitions(f.m) as edges:
f.trigger_stuff()
assert edges.all_transitions() == Foo.m.all_transitions()
(the difference between a machine instance, like Foo.m
, and a transitioner instance, like f.m
, is pretty important, both for implementation and for discoverability/learnability/error-reporting. my example probably gets at least one of them wrong)
This also avoids the need to be able to name specific transitions, since the sets contain opaque objects (one per transition). This would let us continue to keep the tracing function private, and these opaque objects would be the strings or tuples that the tracing function provides.
Other questions:
Automat should have a test helper that asserts all transitions occurred.
It might go a little something like this:
...where the tracer stuff would come from #36