added __str__
This commit is contained in:
parent
47f1fb1690
commit
9464736551
@ -164,6 +164,10 @@ class StateMachine(object):
|
|||||||
'''
|
'''
|
||||||
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,10 +20,13 @@ 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"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user