<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> import pytest <EOL> from cocos . director import director <EOL> from cocos . scene import Scene <EOL> director . init ( ) <EOL> rec = [ ] <EOL> class Test_run ( object ) : <EOL> def test_0_initial_state ( self ) : <EOL> assert director . scene is None <EOL> assert director . next_scene is None <EOL> assert len ( director . scene_stack ) == <NUM_LIT:0> <EOL> def test_1_run_once_and_twice ( self ) : <EOL> scene0 = Scene ( ) <EOL> old_stack = list ( director . scene_stack ) <EOL> director . run ( scene0 ) <EOL> assert director . scene is scene0 <EOL> assert director . next_scene is None <EOL> assert director . scene_stack == old_stack <EOL> def test_2_push_delegates_to_on_push ( self ) : <EOL> scene0 = director . scene <EOL> scene1 = Scene ( ) <EOL> director . _utest_recorded_events = [ ] <EOL> director . push ( scene1 ) <EOL> evtype , args = director . _utest_recorded_events [ <NUM_LIT:0> ] <EOL> assert evtype == "<STR_LIT>" <EOL> assert args == ( scene1 , ) <EOL> def test_3_pop_delegates_to_on_pop ( self ) : <EOL> director . _utest_recorded_events = [ ] <EOL> director . pop ( ) <EOL> evtype , args = director . _utest_recorded_events [ <NUM_LIT:0> ] <EOL> assert evtype == "<STR_LIT>" <EOL> assert args == ( ) <EOL> def test_4_on_push_on_pop_and_current_scene ( self ) : <EOL> scene0 = director . scene <EOL> scene1 = Scene ( ) <EOL> scene2 = Scene ( ) <EOL> director . on_push ( scene1 ) <EOL> director . on_draw ( ) <EOL> assert director . scene is scene1 <EOL> director . on_push ( scene2 ) <EOL> director . on_draw ( ) <EOL> assert director . scene is scene2 <EOL> director . on_pop ( ) <EOL> director . on_draw ( ) <EOL> assert director . scene is scene1 <EOL> director . on_pop ( ) <EOL> director . on_draw ( ) <EOL> assert director . scene is scene0 <EOL> def test_5_on_push_calls_on_enter_on_exit ( self ) : <EOL> global rec <EOL> scene0 = Scene ( ) <EOL> scene1 = Scene ( ) <EOL> def on_exit ( ) : <EOL> global rec <EOL> rec . append ( '<STR_LIT>' ) <EOL> def on_enter ( ) : <EOL> global rec <EOL> rec . append ( '<STR_LIT>' ) <EOL> scene0 . on_exit = on_exit <EOL> scene1 . on_enter = on_enter <EOL> rec = [ ] <EOL> director . on_push ( scene0 ) <EOL> director . on_draw ( ) <EOL> rec = [ ] <EOL> director . on_push ( scene1 ) <EOL> director . on_draw ( ) <EOL> assert rec [ <NUM_LIT:0> ] == '<STR_LIT>' <EOL> assert rec [ <NUM_LIT:1> ] == '<STR_LIT>' <EOL> def test_6_on_pop_calls_on_enter_on_exit ( self ) : <EOL> global rec <EOL> scene0 = Scene ( ) <EOL> scene1 = Scene ( ) <EOL> def on_exit ( ) : <EOL> global rec <EOL> rec . append ( '<STR_LIT>' ) <EOL> def on_enter ( ) : <EOL> global rec <EOL> rec . append ( '<STR_LIT>' ) <EOL> scene0 . on_enter = on_enter <EOL> scene1 . on_exit = on_exit <EOL> rec = [ ] <EOL> director . on_push ( scene0 ) <EOL> director . on_draw ( ) <EOL> director . on_push ( scene1 ) <EOL> director . on_draw ( ) <EOL> rec = [ ] <EOL> director . on_pop ( ) <EOL> director . on_draw ( ) <EOL> assert rec [ <NUM_LIT:0> ] == '<STR_LIT>' <EOL> assert rec [ <NUM_LIT:1> ] == '<STR_LIT>' <EOL> def test_7_replace ( self ) : <EOL> global rec <EOL> scene0 = Scene ( ) <EOL> scene1 = Scene ( ) <EOL> scene2 = Scene ( ) <EOL> def on_exit ( ) : <EOL> global rec <EOL> rec . append ( '<STR_LIT>' ) <EOL> def on_enter ( ) : <EOL> global rec <EOL> rec . append ( '<STR_LIT>' ) <EOL> scene1 . on_exit = on_exit <EOL> scene2 . on_enter = on_enter <EOL> director . on_push ( scene0 ) <EOL> director . on_draw ( ) <EOL> director . on_push ( scene1 ) <EOL> director . on_draw ( ) <EOL> rec = [ ] <EOL> director . replace ( scene2 ) <EOL> director . on_draw ( ) <EOL> assert director . scene is scene2 <EOL> assert rec [ <NUM_LIT:0> ] == '<STR_LIT>' <EOL> assert rec [ <NUM_LIT:1> ] == '<STR_LIT>' <EOL> director . on_pop ( ) <EOL> director . on_draw ( ) <EOL> assert director . scene is scene0 <EOL> class TestRunningScene ( object ) : <EOL> """<STR_LIT>""" <EOL> def test_0_replace ( self ) : <EOL> scene = Scene ( ) <EOL> director . run ( scene ) <EOL> new_scene = Scene ( ) <EOL> new_scene . parent = not_None_value <EOL> director . replace ( new_scene ) <EOL> director . on_draw ( ) <EOL> assert new_scene . parent is None <EOL> def test_1_push ( self ) : <EOL> old_scene = Scene ( ) <EOL> director . run ( old_scene ) <EOL> new_scene = Scene ( ) <EOL> new_scene . parent = not_None_value <EOL> director . on_push ( new_scene ) <EOL> director . on_draw ( ) <EOL> assert new_scene . parent is None <EOL> def test_2_pop ( self ) : <EOL> scene = Scene ( ) <EOL> director . run ( scene ) <EOL> new_scene = Scene ( ) <EOL> director . on_push ( new_scene ) <EOL> director . on_draw ( ) <EOL> scene . parent = not_None_value <EOL> director . on_pop ( ) <EOL> director . on_draw ( ) <EOL> assert scene . parent is None <EOL> class NotNone ( object ) : <EOL> pass <EOL> not_None_value = NotNone ( ) </s>
