<s> import unittest <EOL> import pyglet . window . key as pkey <EOL> from mock import patch <EOL> from victor . app import VIctorApp <EOL> import victor . mode as vmode <EOL> class AppTest ( unittest . TestCase ) : <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_switch_to_ex_mode_on_text_then_on_key_press_event ( self , setup_cursor , window_init ) : <EOL> app = VIctorApp ( ) <EOL> self . assertFalse ( app . is_ex_mode ( ) ) <EOL> app . on_text ( '<STR_LIT::>' ) <EOL> self . assertFalse ( app . is_ex_mode ( ) ) <EOL> app . on_key_press ( pkey . SEMICOLON , pkey . MOD_SHIFT ) <EOL> self . assertTrue ( app . is_ex_mode ( ) ) <EOL> self . assertEqual ( app . command_area . text , '<STR_LIT::>' ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_switch_to_ex_mode_on_key_press_then_on_text_event ( self , setup_cursor , window_init ) : <EOL> app = VIctorApp ( ) <EOL> self . assertFalse ( app . is_ex_mode ( ) ) <EOL> app . on_key_press ( pkey . SEMICOLON , pkey . MOD_SHIFT ) <EOL> self . assertFalse ( app . is_ex_mode ( ) ) <EOL> app . on_text ( '<STR_LIT::>' ) <EOL> self . assertTrue ( app . is_ex_mode ( ) ) <EOL> self . assertEqual ( app . command_area . text , '<STR_LIT::>' ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_switch_back_to_normal_mode_when_leading_colon_is_deleted ( <EOL> self , setup_cursor , window_init <EOL> ) : <EOL> app = VIctorApp ( ) <EOL> app . switch_to_ex_mode ( ) <EOL> self . assertTrue ( app . is_ex_mode ( ) ) <EOL> app . on_text_motion ( pkey . MOTION_BACKSPACE ) <EOL> self . assertTrue ( app . is_normal_mode ( ) ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_escape_switches_to_normal_mode_from_ex_mode ( self , setup_cursor , window_init ) : <EOL> app = VIctorApp ( ) <EOL> app . switch_to_ex_mode ( ) <EOL> self . assertTrue ( app . is_ex_mode ( ) ) <EOL> app . on_key_press ( pkey . ESCAPE , <NUM_LIT> ) <EOL> self . assertTrue ( app . is_normal_mode ( ) ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_ctrl_left_bracket_switches_to_normal_mode_from_ex_mode ( self , setup_cursor , window_init ) : <EOL> app = VIctorApp ( ) <EOL> app . switch_to_ex_mode ( ) <EOL> self . assertTrue ( app . is_ex_mode ( ) ) <EOL> app . on_key_press ( pkey . BRACKETLEFT , pkey . MOD_CTRL ) <EOL> self . assertTrue ( app . is_normal_mode ( ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
