<s> from nose . tools import assert_equals , assert_true , assert_false <EOL> from statemachine import event , Machine , before_transition <EOL> class Hunger ( Machine ) : <EOL> initial_state = '<STR_LIT>' <EOL> @ event <EOL> def eat ( self ) : <EOL> yield '<STR_LIT>' , '<STR_LIT>' <EOL> yield '<STR_LIT>' , '<STR_LIT>' <EOL> yield '<STR_LIT>' , '<STR_LIT>' <EOL> @ event <EOL> def rest ( self ) : <EOL> yield ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , '<STR_LIT>' <EOL> class WildHunger ( Hunger ) : <EOL> @ event <EOL> def rest ( self ) : <EOL> yield '<STR_LIT:*>' , '<STR_LIT>' <EOL> def test_hunger ( ) : <EOL> light = Hunger ( ) <EOL> assert_equals ( '<STR_LIT>' , light . state ) <EOL> light . eat ( ) <EOL> assert_equals ( '<STR_LIT>' , light . state ) <EOL> light . eat ( ) <EOL> assert_equals ( '<STR_LIT>' , light . state ) <EOL> light . eat ( ) <EOL> assert_equals ( '<STR_LIT>' , light . state ) <EOL> def test_wild_hunger ( ) : <EOL> light = WildHunger ( ) <EOL> assert_equals ( '<STR_LIT>' , light . state ) <EOL> light . eat ( ) <EOL> assert_equals ( '<STR_LIT>' , light . state ) <EOL> light . rest ( ) <EOL> assert_equals ( '<STR_LIT>' , light . state ) </s>
