<s> import os <EOL> import sys <EOL> from unittest import defaultTestLoader , TextTestRunner , TestSuite <EOL> TESTS = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> OPTIONAL_TESTS = ( '<STR_LIT>' , ) <EOL> def make_suite ( prefix = '<STR_LIT>' , extra = ( ) , force_all = False ) : <EOL> tests = TESTS + extra <EOL> test_names = list ( prefix + x for x in tests ) <EOL> suite = TestSuite ( ) <EOL> suite . addTest ( defaultTestLoader . loadTestsFromNames ( test_names ) ) <EOL> for name in OPTIONAL_TESTS : <EOL> test_name = prefix + name <EOL> try : <EOL> suite . addTest ( defaultTestLoader . loadTestsFromName ( test_name ) ) <EOL> except ( ImportError , AttributeError ) : <EOL> if force_all : <EOL> raise ImportError ( '<STR_LIT>' % test_name ) <EOL> sys . stderr . write ( "<STR_LIT>" % name ) <EOL> return suite <EOL> def additional_tests ( ) : <EOL> """<STR_LIT>""" <EOL> return make_suite ( '<STR_LIT>' ) <EOL> def main ( ) : <EOL> my_dir = os . path . dirname ( os . path . abspath ( __file__ ) ) <EOL> sys . path . insert ( <NUM_LIT:0> , os . path . abspath ( os . path . join ( my_dir , '<STR_LIT:..>' ) ) ) <EOL> from optparse import OptionParser <EOL> parser = OptionParser ( ) <EOL> parser . add_option ( '<STR_LIT>' , action = '<STR_LIT:store_true>' , dest = '<STR_LIT>' , default = False ) <EOL> parser . add_option ( '<STR_LIT>' , action = '<STR_LIT:store_true>' , dest = '<STR_LIT>' , default = False ) <EOL> parser . add_option ( '<STR_LIT>' , '<STR_LIT>' , action = '<STR_LIT:count>' , dest = '<STR_LIT>' , default = <NUM_LIT:0> ) <EOL> parser . add_option ( '<STR_LIT>' , '<STR_LIT>' , action = '<STR_LIT:count>' , dest = '<STR_LIT>' , default = <NUM_LIT:0> ) <EOL> options , extra_args = parser . parse_args ( ) <EOL> has_pep8 = False <EOL> try : <EOL> import pep8 <EOL> has_pep8 = True <EOL> except ImportError : <EOL> if options . with_pep8 : <EOL> sys . stderr . write ( '<STR_LIT>' ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> if has_pep8 : <EOL> guide_main = pep8 . StyleGuide ( <EOL> ignore = [ ] , <EOL> paths = [ '<STR_LIT>' ] , <EOL> exclude = [ ] , <EOL> max_line_length = <NUM_LIT> , <EOL> ) <EOL> guide_tests = pep8 . StyleGuide ( <EOL> ignore = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> paths = [ '<STR_LIT>' ] , <EOL> max_line_length = <NUM_LIT> , <EOL> ) <EOL> for guide in ( guide_main , guide_tests ) : <EOL> report = guide . check_files ( ) <EOL> if report . total_errors : <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> suite = make_suite ( '<STR_LIT>' , tuple ( extra_args ) , options . force_all ) <EOL> runner = TextTestRunner ( verbosity = options . verbosity - options . quietness + <NUM_LIT:1> ) <EOL> result = runner . run ( suite ) <EOL> sys . exit ( not result . wasSuccessful ( ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
