<s> import sys <EOL> import logging <EOL> import unittest <EOL> try : <EOL> from unittest import skip as _skip <EOL> except ImportError : <EOL> import unittest2 as unittest <EOL> testmodules = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> """<STR_LIT>""" <EOL> def get_testsuites_in_module ( module ) : <EOL> """<STR_LIT>""" <EOL> suites = [ ] <EOL> for name in dir ( module ) : <EOL> obj = getattr ( module , name ) <EOL> if isinstance ( obj , type ) and issubclass ( obj , unittest . TestSuite ) : <EOL> suites . append ( obj ) <EOL> return suites <EOL> def load_tests_in_modules ( modulenames ) : <EOL> """<STR_LIT>""" <EOL> loader = unittest . TestLoader ( ) <EOL> suites = [ ] <EOL> for name in modulenames : <EOL> module = __import__ ( name ) <EOL> suite = loader . loadTestsFromModule ( module ) <EOL> for suiteclass in get_testsuites_in_module ( module ) : <EOL> suite = suiteclass ( suite ) <EOL> suites . append ( suite ) <EOL> suite = unittest . TestSuite ( suites ) <EOL> return suite <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> logger = logging . getLogger ( "<STR_LIT>" ) <EOL> if len ( logger . handlers ) == <NUM_LIT:0> : <EOL> logging . basicConfig ( level = logging . INFO , stream = sys . stderr , format = '<STR_LIT>' ) <EOL> testresult = unittest . TextTestRunner ( verbosity = <NUM_LIT:2> ) . run ( load_tests_in_modules ( testmodules ) ) <EOL> sys . exit ( <NUM_LIT:0> if testresult . wasSuccessful ( ) else <NUM_LIT:1> ) </s>
