diff options
author | Thom Nichols <tmnichols@gmail.com> | 2010-06-07 13:58:15 -0400 |
---|---|---|
committer | Thom Nichols <tmnichols@gmail.com> | 2010-06-07 13:58:15 -0400 |
commit | 9464736551311c015f1511e7535c762923838eaf (patch) | |
tree | 8815916d4a872aaa9bd1ed67d1540d3a722dbe57 | |
parent | 47f1fb16909d3baaec5822b1dcbca89491d0d18c (diff) | |
download | slixmpp-9464736551311c015f1511e7535c762923838eaf.tar.gz slixmpp-9464736551311c015f1511e7535c762923838eaf.tar.bz2 slixmpp-9464736551311c015f1511e7535c762923838eaf.tar.xz slixmpp-9464736551311c015f1511e7535c762923838eaf.zip |
added __str__
-rw-r--r-- | sleekxmpp/xmlstream/statemachine.py | 4 | ||||
-rw-r--r-- | 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')) |