From 9464736551311c015f1511e7535c762923838eaf Mon Sep 17 00:00:00 2001 From: Thom Nichols Date: Mon, 7 Jun 2010 13:58:15 -0400 Subject: added __str__ --- sleekxmpp/xmlstream/statemachine.py | 4 ++++ tests/test_statemachine.py | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/sleekxmpp/xmlstream/statemachine.py b/sleekxmpp/xmlstream/statemachine.py index b1ab7574..704cabdb 100644 --- a/sleekxmpp/xmlstream/statemachine.py +++ b/sleekxmpp/xmlstream/statemachine.py @@ -163,6 +163,10 @@ class StateMachine(object): Use `StateMachine.ensure(state)` to wait until the machine enters a certain state. ''' return self.__current_state == state + + def __str__(self): + return "".join(( "StateMachine(", ','.join(self.__states), "): ", self.__current_state )) + class _StateCtx: diff --git a/tests/test_statemachine.py b/tests/test_statemachine.py index 0173ff09..00e4d3a3 100644 --- a/tests/test_statemachine.py +++ b/tests/test_statemachine.py @@ -20,11 +20,14 @@ class testStateMachine(unittest.TestCase): # self.failIf(s.two) self.failIf(s['two']) try: - s.booga + s['booga'] self.fail('s.booga is an invalid state and should throw an exception!') except: pass #expected exception - + # just make sure __str__ works, no reason to test its exact value: + print str(s) + + def testTransitions(self): "Test ensure transitions occur correctly in a single thread" s = sm.StateMachine(('one','two','three')) -- cgit v1.2.3