#NEWLINE# def test_setup_teardown_order_with_pathological_suite( self ) : #NEWLINE# #INDENT# results = [ ] #NEWLINE# class Module1 ( object ) : #NEWLINE# #INDENT# @ staticmethod #NEWLINE# def setUpModule( ) : #NEWLINE# #INDENT# results . append ( 'Module1.setUpModule' ) #NEWLINE# #UNINDENT# @ staticmethod #NEWLINE# def tearDownModule( ) : #NEWLINE# #INDENT# results . append ( 'Module1.tearDownModule' ) #NEWLINE# #UNINDENT# #UNINDENT# class Module2 ( object ) : #NEWLINE# #INDENT# @ staticmethod #NEWLINE# def setUpModule( ) : #NEWLINE# #INDENT# results . append ( 'Module2.setUpModule' ) #NEWLINE# #UNINDENT# @ staticmethod #NEWLINE# def tearDownModule( ) : #NEWLINE# #INDENT# results . append ( 'Module2.tearDownModule' ) #NEWLINE# #UNINDENT# #UNINDENT# class Test1 ( unittest . TestCase ) : #NEWLINE# #INDENT# @ classmethod #NEWLINE# def setUpClass( cls ) : #NEWLINE# #INDENT# results . append ( 'setup 1' ) #NEWLINE# #UNINDENT# @ classmethod #NEWLINE# def tearDownClass( cls ) : #NEWLINE# #INDENT# results . append ( 'teardown 1' ) #NEWLINE# #UNINDENT# def testOne( self ) : #NEWLINE# #INDENT# results . append ( 'Test1.testOne' ) #NEWLINE# #UNINDENT# def testTwo( self ) : #NEWLINE# #INDENT# results . append ( 'Test1.testTwo' ) #NEWLINE# #UNINDENT# #UNINDENT# class Test2 ( unittest . TestCase ) : #NEWLINE# #INDENT# @ classmethod #NEWLINE# def setUpClass( cls ) : #NEWLINE# #INDENT# results . append ( 'setup 2' ) #NEWLINE# #UNINDENT# @ classmethod #NEWLINE# def tearDownClass( cls ) : #NEWLINE# #INDENT# results . append ( 'teardown 2' ) #NEWLINE# #UNINDENT# def testOne( self ) : #NEWLINE# #INDENT# results . append ( 'Test2.testOne' ) #NEWLINE# #UNINDENT# def testTwo( self ) : #NEWLINE# #INDENT# results . append ( 'Test2.testTwo' ) #NEWLINE# #UNINDENT# #UNINDENT# class Test3 ( unittest . TestCase ) : #NEWLINE# #INDENT# @ classmethod #NEWLINE# def setUpClass( cls ) : #NEWLINE# #INDENT# results . append ( 'setup 3' ) #NEWLINE# #UNINDENT# @ classmethod #NEWLINE# def tearDownClass( cls ) : #NEWLINE# #INDENT# results . append ( 'teardown 3' ) #NEWLINE# #UNINDENT# def testOne( self ) : #NEWLINE# #INDENT# results . append ( 'Test3.testOne' ) #NEWLINE# #UNINDENT# def testTwo( self ) : #NEWLINE# #INDENT# results . append ( 'Test3.testTwo' ) #NEWLINE# #UNINDENT# #UNINDENT# Test1 . __module__ = Test2 . __module__ = 'Module' #NEWLINE# Test3 . __module__ = 'Module2' #NEWLINE# sys . modules [ 'Module' ] = Module1 #NEWLINE# sys . modules [ 'Module2' ] = Module2 #NEWLINE# first = unittest . TestSuite ( ( Test1 ( 'testOne' ) , ) ) #NEWLINE# second = unittest . TestSuite ( ( Test1 ( 'testTwo' ) , ) ) #NEWLINE# third = unittest . TestSuite ( ( Test2 ( 'testOne' ) , ) ) #NEWLINE# fourth = unittest . TestSuite ( ( Test2 ( 'testTwo' ) , ) ) #NEWLINE# fifth = unittest . TestSuite ( ( Test3 ( 'testOne' ) , ) ) #NEWLINE# sixth = unittest . TestSuite ( ( Test3 ( 'testTwo' ) , ) ) #NEWLINE# suite = unittest . TestSuite ( ( first , second , third , fourth , fifth , sixth ) ) #NEWLINE# runner = self . getRunner ( ) #NEWLINE# result = runner . run ( suite ) #NEWLINE# self . assertEqual ( result . testsRun , 6 ) #NEWLINE# self . assertEqual ( len ( result . errors ) , 0 ) #NEWLINE# self . assertEqual ( results , [ 'Module1.setUpModule' , 'setup 1' , 'Test1.testOne' , 'Test1.testTwo' , 'teardown 1' , 'setup 2' , 'Test2.testOne' , 'Test2.testTwo' , 'teardown 2' , 'Module1.tearDownModule' , 'Module2.setUpModule' , 'setup 3' , 'Test3.testOne' , 'Test3.testTwo' , 'teardown 3' , 'Module2.tearDownModule' ] )