From c8be98880152c083af9daf0d0ab1ac7981430c29 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Sat, 25 Feb 2017 13:13:30 -0800 Subject: [PATCH] add some state-machine tracing needs warner/automat/36-tracing branch --- src/wormhole/_mailbox.py | 2 ++ src/wormhole/test/test_wormhole_new.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/wormhole/_mailbox.py b/src/wormhole/_mailbox.py index 628d40d..f3c9cda 100644 --- a/src/wormhole/_mailbox.py +++ b/src/wormhole/_mailbox.py @@ -10,6 +10,8 @@ from . import _interfaces class Mailbox(object): _side = attrib(validator=instance_of(type(u""))) m = MethodicalMachine() + @m.setTrace() + def setTrace(): pass def __attrs_post_init__(self): self._mood = None diff --git a/src/wormhole/test/test_wormhole_new.py b/src/wormhole/test/test_wormhole_new.py index 6e32a24..c917109 100644 --- a/src/wormhole/test/test_wormhole_new.py +++ b/src/wormhole/test/test_wormhole_new.py @@ -40,6 +40,9 @@ class New(ServerBase, unittest.TestCase): @inlineCallbacks def test_basic(self): w1 = wormhole.deferred_wormhole(APPID, self.relayurl, reactor) + def trace(old_state, input, new_state): + print("W1._M[%s].%s -> [%s]" % (old_state, input, new_state)) + w1._boss._M.setTrace(trace) w1.allocate_code(2) code = yield w1.when_code() print("code:", code)