def init_tests(pep8style):
 report = pep8style.init_report(TestReport)
 runner = pep8style.input_file
 def run_tests(filename):
  'Run all the tests from a file.'
  lines = (readlines(filename) + ['#:\n'])
  line_offset = 0
  codes = ['Okay']
  testcase = []
  count_files = report.counters['files']
  for (index, line) in enumerate(lines):
   if (not line.startswith('#:')):
    if codes:
     testcase.append(line)
    continue
   if (codes and index):
    if ('noeol' in codes):
     testcase[(-1)] = testcase[(-1)].rstrip('\n')
    codes = [c for c in codes if (c not in ('Okay', 'noeol'))]
    runner(filename, testcase, expected=codes, line_offset=line_offset)
   line_offset = (index + 1)
   codes = line.split()[1:]
   del testcase[:]
  report.counters['files'] = (count_files + 1)
  return report.counters['failed tests']
 pep8style.runner = run_tests

def init_tests ( pep8style ) : report = pep8style . init_report ( TestReport ) runner = pep8style . input_file def run_tests ( filename ) : lines = ( readlines ( filename ) + [ '#:\n' ] ) line_offset = 0 codes = [ 'Okay' ] testcase = [ ] count_files = report . counters [ 'files' ] for ( index , line ) in enumerate ( lines ) : if ( not line . startswith ( '#:' ) ) : if codes : testcase . append ( line ) continue if ( codes and index ) : if ( 'noeol' in codes ) : testcase [ ( - 1 ) ] = testcase [ ( - 1 ) ] . rstrip ( '\n' ) codes = [ c for c in codes if ( c not in ( 'Okay' , 'noeol' ) ) ] runner ( filename , testcase , expected = codes , line_offset = line_offset ) line_offset = ( index + 1 ) codes = line . split ( ) [ 1 : ] del testcase [ : ] report . counters [ 'files' ] = ( count_files + 1 ) return report . counters [ 'failed tests' ] pep8style . runner = run_tests
initialize testing framework .