<s> import sys <EOL> from optparse import OptionParser <EOL> try : <EOL> from coverage import coverage <EOL> except ImportError : <EOL> coverage = None <EOL> parser = OptionParser ( ) <EOL> parser . add_option ( '<STR_LIT>' , '<STR_LIT>' , action = '<STR_LIT:store_true>' , <EOL> help = '<STR_LIT>' ) <EOL> if coverage : <EOL> parser . add_option ( '<STR_LIT:-c>' , '<STR_LIT>' , action = '<STR_LIT:store_true>' , <EOL> help = '<STR_LIT>' ) <EOL> options , args = parser . parse_args ( ) <EOL> if args : <EOL> parser . print_help ( ) <EOL> sys . exit ( <NUM_LIT:2> ) <EOL> if coverage and options . coverage : <EOL> cov = coverage ( ) <EOL> cov . start ( ) <EOL> import tests <EOL> result = tests . run ( options . verbose ) <EOL> if result . wasSuccessful ( ) and options . coverage : <EOL> exclude = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> def include_module ( name ) : <EOL> for prefix in [ '<STR_LIT>' , '<STR_LIT>' ] : <EOL> if name . startswith ( prefix ) : <EOL> return False <EOL> return name . startswith ( '<STR_LIT>' ) <EOL> cov . stop ( ) <EOL> modules = [ <EOL> module for name , module in sys . modules . items ( ) <EOL> if include_module ( name ) <EOL> ] <EOL> cov . report ( modules , file = sys . stdout ) <EOL> cov . erase ( ) </s>
