added __str__
This commit is contained in:
parent
47f1fb1690
commit
9464736551
@ -163,6 +163,10 @@ class StateMachine(object):
|
|||||||
Use `StateMachine.ensure(state)` to wait until the machine enters a certain state.
|
Use `StateMachine.ensure(state)` to wait until the machine enters a certain state.
|
||||||
'''
|
'''
|
||||||
return self.__current_state == state
|
return self.__current_state == state
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return "".join(( "StateMachine(", ','.join(self.__states), "): ", self.__current_state ))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class _StateCtx:
|
class _StateCtx:
|
||||||
|
@ -20,11 +20,14 @@ class testStateMachine(unittest.TestCase):
|
|||||||
# self.failIf(s.two)
|
# self.failIf(s.two)
|
||||||
self.failIf(s['two'])
|
self.failIf(s['two'])
|
||||||
try:
|
try:
|
||||||
s.booga
|
s['booga']
|
||||||
self.fail('s.booga is an invalid state and should throw an exception!')
|
self.fail('s.booga is an invalid state and should throw an exception!')
|
||||||
except: pass #expected exception
|
except: pass #expected exception
|
||||||
|
|
||||||
|
# just make sure __str__ works, no reason to test its exact value:
|
||||||
|
print str(s)
|
||||||
|
|
||||||
|
|
||||||
def testTransitions(self):
|
def testTransitions(self):
|
||||||
"Test ensure transitions occur correctly in a single thread"
|
"Test ensure transitions occur correctly in a single thread"
|
||||||
s = sm.StateMachine(('one','two','three'))
|
s = sm.StateMachine(('one','two','three'))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user