#NEWLINE# def test_watchdog( self ) : #NEWLINE# #INDENT# '\n        The watchdog thread exits when the thread it is watching exits, and\n        calls its shutdown function.\n        ' #NEWLINE# done = [ ] #NEWLINE# alive = True #NEWLINE# class FakeThread ( ) : #NEWLINE# #INDENT# def is_alive( self ) : #NEWLINE# #INDENT# return alive #NEWLINE# #UNINDENT# #UNINDENT# w = Watchdog ( FakeThread ( ) , ( lambda : done . append ( True ) ) ) #NEWLINE# w . start ( ) #NEWLINE# time . sleep ( 0.2 ) #NEWLINE# self . assertTrue ( w . is_alive ( ) ) #NEWLINE# self . assertFalse ( alive ) #NEWLINE# alive = False #NEWLINE# time . sleep ( 0.2 ) #NEWLINE# self . assertTrue ( done ) #NEWLINE# self . assertFalse ( w . is_alive ( ) )