#NEWLINE# def test_calls_setUp_test_tearDown_in_sequence( self ) : #NEWLINE# #INDENT# call_log = [ ] #NEWLINE# a = defer . Deferred ( ) #NEWLINE# a . addCallback ( ( lambda x : call_log . append ( 'a' ) ) ) #NEWLINE# b = defer . Deferred ( ) #NEWLINE# b . addCallback ( ( lambda x : call_log . append ( 'b' ) ) ) #NEWLINE# c = defer . Deferred ( ) #NEWLINE# c . addCallback ( ( lambda x : call_log . append ( 'c' ) ) ) #NEWLINE# class SomeCase ( TestCase ) : #NEWLINE# #INDENT# def setUp( self ) : #NEWLINE# #INDENT# super ( SomeCase , self ) . setUp ( ) #NEWLINE# call_log . append ( 'setUp' ) #NEWLINE# return a #NEWLINE# #UNINDENT# def test_success( self ) : #NEWLINE# #INDENT# call_log . append ( 'test' ) #NEWLINE# return b #NEWLINE# #UNINDENT# def tearDown( self ) : #NEWLINE# #INDENT# super ( SomeCase , self ) . tearDown ( ) #NEWLINE# call_log . append ( 'tearDown' ) #NEWLINE# return c #NEWLINE# #UNINDENT# #UNINDENT# test = SomeCase ( 'test_success' ) #NEWLINE# timeout = self . make_timeout ( ) #NEWLINE# runner = self . make_runner ( test , call_log ) #NEWLINE# result = self . make_result ( ) #NEWLINE# reactor = self . make_reactor ( ) #NEWLINE# def fire_a( ) : #NEWLINE# #INDENT# self . assertThat ( call_log , Equals ( [ 'setUp' ] ) ) #NEWLINE# a . callback ( None ) #NEWLINE# #UNINDENT# def fire_b( ) : #NEWLINE# #INDENT# self . assertThat ( call_log , Equals ( [ 'setUp' , 'a' , 'test' ] ) ) #NEWLINE# b . callback ( None ) #NEWLINE# #UNINDENT# def fire_c( ) : #NEWLINE# #INDENT# self . assertThat ( call_log , Equals ( [ 'setUp' , 'a' , 'test' , 'b' , 'tearDown' ] ) ) #NEWLINE# c . callback ( None ) #NEWLINE# #UNINDENT# reactor . callLater ( ( timeout * 0.25 ) , fire_a ) #NEWLINE# reactor . callLater ( ( timeout * 0.5 ) , fire_b ) #NEWLINE# reactor . callLater ( ( timeout * 0.75 ) , fire_c ) #NEWLINE# runner . run ( result ) #NEWLINE# self . assertThat ( call_log , Equals ( [ 'setUp' , 'a' , 'test' , 'b' , 'tearDown' , 'c' ] ) )