def test_translate_cpp_to_python(self, input_path):
     reader = CodeReader()
     cpp_code = reader.read_file(input_path)
     language_from = Language.find('C++')
     language_to = Language.find('Python')
     translator = AutoTranslator(language_from, language_to,
                                 ast_generalizer_kwargs={'scope': {'path': input_path}})
     python_code = translator.translate(cpp_code, input_path)
     basic_check_python_code(self, input_path, python_code)
 def test_translate_c_to_python(self, input_path):
     reader = CodeReader()
     c_code = reader.read_file(input_path)
     language_from = Language.find('C11')
     language_to = Language.find('Python')
     translator = AutoTranslator(language_from, language_to)
     with _TIME.measure('translate.c11_to_python3.{}'
                        .format(input_path.name.replace('.', '_'))) as timer:
         python_code = translator.translate(c_code, input_path)
     basic_check_python_code(self, input_path, python_code)
     _LOG.info('translated "%s" to Python in %fs', input_path, timer.elapsed)
 def test_translate_python_to_cpp(self, input_path):
     reader = CodeReader()
     python_code = reader.read_file(input_path)
     language_from = Language.find('Python')
     language_to = Language.find('C++')
     translator = AutoTranslator(language_from, language_to)
     with _TIME.measure('translate.python3_to_cpp14.{}'
                        .format(input_path.name.replace('.', '_'))) as timer:
         cpp_code = translator.translate(python_code)
     basic_check_cpp_code(self, input_path, cpp_code)
     _LOG.info('translated "%s" to C++ in %fs', input_path, timer.elapsed)
 def test_python_to_cpp(self):
     language_from = Language.find('Python')
     language_to = Language.find('C++')
     reader = CodeReader()
     root = EXAMPLES_ROOTS['python3']
     for input_path in {
             root.joinpath('do_nothing.py'),
             root.joinpath('gemm.py')
     }:
         translator = AutoTranslator(language_from, language_to)
         with self.subTest(input_path=input_path):
             python_code = reader.read_file(input_path)
             cpp_code = translator.translate(python_code)
             basic_check_cpp_code(self, input_path, cpp_code)
 def test_auto_translator_init(self):
     for (_, language_from_name), (_, language_to_name) \
             in itertools.product(EXAMPLES_LANGS_NAMES.items(), EXAMPLES_LANGS_NAMES.items()):
         if language_from_name in NOT_PARSED_LANGS or language_to_name in NOT_UNPARSED_LANGS:
             continue
         with self.subTest(language_from_name=language_from_name,
                           language_to_name=language_to_name):
             from_language = Language.find(language_from_name)
             self.assertIsInstance(from_language, Language)
             to_language = Language.find(language_to_name)
             self.assertIsInstance(to_language, Language)
             translator = AutoTranslator(from_language, to_language)
             self.assertIsInstance(translator, Translator)