<s> from __future__ import division , print_function , unicode_literals <EOL> import os <EOL> assert os . environ [ '<STR_LIT>' ] <EOL> import sys <EOL> sys . path . insert ( <NUM_LIT:0> , '<STR_LIT>' ) <EOL> import pyglet <EOL> assert pyglet . mock_level == <NUM_LIT:1> <EOL> from cocos . director import director <EOL> from cocos . cocosnode import CocosNode <EOL> import cocos . actions as ac <EOL> import sys <EOL> director . init ( ) <EOL> rec = [ ] <EOL> next_done = <NUM_LIT:0> <EOL> class UAction ( ac . Action ) : <EOL> def init ( self , name ) : <EOL> rec . append ( ( name , '<STR_LIT>' ) ) <EOL> self . name = name <EOL> def start ( self ) : <EOL> rec . append ( ( self . name , '<STR_LIT:start>' ) ) <EOL> def step ( self , dt ) : <EOL> global rec , next_done <EOL> rec . append ( ( self . name , '<STR_LIT>' , dt ) ) <EOL> if int ( self . name ) & next_done : <EOL> print ( '<STR_LIT>' % self . name ) <EOL> self . _done = True <EOL> def stop ( self ) : <EOL> rec . append ( ( self . name , '<STR_LIT>' ) ) <EOL> class Test_cocosnode_actions_functionality : <EOL> def test_initial_actions_container_empty ( self ) : <EOL> node = CocosNode ( ) <EOL> assert len ( node . actions ) == <NUM_LIT:0> <EOL> def test_do_inmediate_effects1 ( self ) : <EOL> global rec , next_done <EOL> next_done = <NUM_LIT:0> <EOL> node = CocosNode ( ) <EOL> name1 = '<STR_LIT:1>' <EOL> action = UAction ( name1 ) <EOL> rec = [ ] <EOL> a_copy = node . do ( action ) <EOL> assert a_copy . target == node <EOL> assert a_copy in node . actions <EOL> assert len ( node . actions ) == <NUM_LIT:1> <EOL> assert rec [ <NUM_LIT:0> ] == ( name1 , '<STR_LIT:start>' ) <EOL> assert len ( rec ) == <NUM_LIT:1> <EOL> def test_do_inmediate_effects2 ( self ) : <EOL> global rec , next_done <EOL> next_done = <NUM_LIT:0> <EOL> node = CocosNode ( ) <EOL> name1 = '<STR_LIT:1>' <EOL> action = UAction ( name1 ) <EOL> my_target = '<STR_LIT>' <EOL> rec = [ ] <EOL> a_copy = node . do ( action , target = my_target ) <EOL> assert a_copy . target == my_target <EOL> assert a_copy in node . actions <EOL> assert len ( node . actions ) == <NUM_LIT:1> <EOL> assert rec [ <NUM_LIT:0> ] == ( name1 , '<STR_LIT:start>' ) <EOL> assert len ( rec ) == <NUM_LIT:1> <EOL> def test_actions_stepping_without_completion ( self ) : <EOL> global rec , next_done <EOL> next_done = <NUM_LIT:0> <EOL> node = CocosNode ( ) <EOL> name1 = '<STR_LIT:1>' <EOL> action1 = UAction ( name1 ) <EOL> name2 = '<STR_LIT:2>' <EOL> action2 = UAction ( name2 ) <EOL> a1_copy = node . do ( action1 ) <EOL> a2_copy = node . do ( action2 ) <EOL> rec = [ ] <EOL> dt = <NUM_LIT:0.1> <EOL> node . _step ( dt ) <EOL> recx = [ e for e in rec if e [ <NUM_LIT:0> ] == name1 ] <EOL> assert recx [ <NUM_LIT:0> ] == ( name1 , '<STR_LIT>' , dt ) <EOL> assert len ( recx ) == <NUM_LIT:1> <EOL> recx = [ e for e in rec if e [ <NUM_LIT:0> ] == name2 ] <EOL> assert recx [ <NUM_LIT:0> ] == ( name2 , '<STR_LIT>' , dt ) <EOL> assert len ( recx ) == <NUM_LIT:1> <EOL> def test_remove_action ( self ) : <EOL> global rec , next_done <EOL> next_done = <NUM_LIT:0> <EOL> node = CocosNode ( ) <EOL> name1 = '<STR_LIT:1>' <EOL> action1 = UAction ( name1 ) <EOL> name2 = '<STR_LIT:2>' <EOL> action2 = UAction ( name2 ) <EOL> a1_copy = node . do ( action1 ) <EOL> a2_copy = node . do ( action2 ) <EOL> assert len ( node . actions ) == <NUM_LIT:2> <EOL> rec = [ ] <EOL> node . remove_action ( a1_copy ) <EOL> recx = [ e for e in rec if e [ <NUM_LIT:0> ] == name1 ] <EOL> assert recx [ <NUM_LIT:0> ] == ( name1 , '<STR_LIT>' ) <EOL> assert len ( recx ) == <NUM_LIT:1> <EOL> rec = [ ] <EOL> dt = <NUM_LIT:0.1> <EOL> node . _step ( dt ) <EOL> assert len ( node . actions ) == <NUM_LIT:1> <EOL> assert a2_copy in node . actions <EOL> recx = [ e for e in rec if e [ <NUM_LIT:0> ] == name1 ] <EOL> assert len ( recx ) == <NUM_LIT:0> <EOL> def test_node_stop_calls_remove_and_not_anything_in_action ( self ) : <EOL> global rec , next_done <EOL> next_done = <NUM_LIT:0> <EOL> node = CocosNode ( ) <EOL> name1 = '<STR_LIT:1>' <EOL> action1 = UAction ( name1 ) <EOL> name2 = '<STR_LIT:2>' <EOL> action2 = UAction ( name2 ) <EOL> a1_copy = node . do ( action1 ) <EOL> a2_copy = node . do ( action2 ) </s>
