def run_main(self, *imported): self.messages = [] code = generate_code(*imported) code = '#!/usr/bin/python\n# -*- coding: utf-8 -*-\n' + code tmp_file = tempfile.mkstemp()[1] try: with codecs.open(tmp_file, 'w', 'utf-8') as f: f.write(code) flake8_future_import.main([tmp_file]) finally: os.remove(tmp_file) self.run_test(self.reverse_parse(self.messages), imported)
def run_main(self, *imported): def iterator(): for fn, line, msg in self.messages: yield int(line), msg self.assertEqual(fn, tmp_file) self.messages = [] code = generate_code(*imported) code = '#!/usr/bin/python\n# -*- coding: utf-8 -*-\n' + code tmp_file = tempfile.mkstemp()[1] try: with codecs.open(tmp_file, 'w', 'utf-8') as f: f.write(code) flake8_future_import.main([tmp_file]) finally: os.remove(tmp_file) self.run_test(iterator(), *imported)