<s> from __future__ import absolute_import <EOL> import os . path <EOL> import tempfile <EOL> import shutil <EOL> from libmodernize . main import main as modernize_main <EOL> def check_on_input ( input_content , expected_content , extra_flags = [ ] ) : <EOL> """<STR_LIT>""" <EOL> tmpdirname = tempfile . mkdtemp ( ) <EOL> try : <EOL> test_input_name = os . path . join ( tmpdirname , "<STR_LIT>" ) <EOL> with open ( test_input_name , "<STR_LIT>" ) as input_file : <EOL> input_file . write ( input_content ) <EOL> def _check ( this_input_content , which_check ) : <EOL> modernize_main ( extra_flags + [ "<STR_LIT>" , test_input_name ] ) <EOL> output_content = "<STR_LIT>" <EOL> with open ( test_input_name , "<STR_LIT>" ) as output_file : <EOL> for line in output_file : <EOL> if line : <EOL> output_content += line <EOL> if output_content != expected_content : <EOL> raise AssertionError ( "<STR_LIT>" % <EOL> ( which_check , this_input_content , output_content , expected_content ) ) <EOL> _check ( input_content , "<STR_LIT>" ) <EOL> if input_content != expected_content : <EOL> _check ( expected_content , "<STR_LIT>" ) <EOL> finally : <EOL> shutil . rmtree ( tmpdirname ) </s>
