#NEWLINE# @ patch ( 'sys.stderr' ) #NEWLINE# def test_clean_pid_files_on_keyboard_interrupt( self , * args ) : #NEWLINE# #INDENT# path = os . path . join ( FIXTURES_PATH , 'clean-pids-app' ) #NEWLINE# initcmd = CommandInit ( ) #NEWLINE# opts = FakeOptions ( app_path = path ) #NEWLINE# initcmd . run ( opts ) #NEWLINE# open ( os . path . join ( app , 'pid/master/3340.pid' ) , 'w' ) #NEWLINE# open ( os . path . join ( path , 'pid/worker/2736.pid' ) , 'w' ) #NEWLINE# open ( os . path . join ( path , 'pid/worker/3847.pid' ) , 'w' ) #NEWLINE# with patch ( 'os.wait' ) : #NEWLINE# #INDENT# with patch ( 'os.getpid' ) : #NEWLINE# #INDENT# os . getpid . side_effect = ( lambda : 3340 ) #NEWLINE# os . wait . side_effect = KeyboardInterrupt ( ) #NEWLINE# cli = Cli ( ) #NEWLINE# cli . options = opts #NEWLINE# cli . log = Mock ( ) #NEWLINE# cli . workers = [ 2736 , 3847 ] #NEWLINE# cli . _wait_workers ( ) #NEWLINE# app = WsgidApp ( path ) #NEWLINE# self . assertEquals ( [ ] , app . master_pids ( ) ) #NEWLINE# self . assertEquals ( [ ] , app . worker_pids ( ) )