class_docstr: Test environment to validate a pythran execution against python. 
class_docstr_tok: ["Test","environment","to","validate","a","pythran","execution","against","python","."]
docstr: Test if a function call return value is equal for Pythran and Pythran.
  
  Args:
     code (str):  python (pythran valid) module to test.
     params (tuple): arguments to pass to the function to test.
     prelude (fct): function to call between 'code' and the c++
                    generated code
     interface (dict): pythran interface for the module to test.
                       Each key is the name of a function to call,
                       the value is a list of the arguments' type.
                       Special keys are 'prelude' and 'check_exception'.
  
  Returns: nothing.
  
  Raises:
     AssertionError by 'unittest' if return value differ.
     SyntaxError if code is not python valid.
     pythran.CompileError if generated code can't be compiled.
     ...possibly others...
docstr_tok: ["Test","if","a","function","call","return","value","is","equal","for","Pythran","and","Pythran",".","Args",":","code","(","str",")",":","python","(","pythran","valid",")","module","to","test",".","params","(","tuple",")",":","arguments","to","pass","to","the","function","to","test",".","prelude","(","fct",")",":","function","to","call","between","'code","'","and","the","c++","generated","code","interface","(","dict",")",":","pythran","interface","for","the","module","to","test",".","Each","key","is","the","name","of","a","function","to","call",",","the","value","is","a","list","of","the","arguments","'","type",".","Special","keys","are","'prelude","'","and","'check_exception","'",".","Returns",":","nothing",".","Raises",":","AssertionError","by","'unittest","'","if","return","value","differ",".","SyntaxError","if","code","is","not","python","valid",".","pythran.CompileError","if","generated","code","ca","n't","be","compiled",".","...","possibly","others","..."]
code: def run_test(self, code, *params, **interface):
      """
      Test if a function call return value is equal for Pythran and Pythran.
  
      Args:
         code (str):  python (pythran valid) module to test.
         params (tuple): arguments to pass to the function to test.
         prelude (fct): function to call between 'code' and the c++
                        generated code
         interface (dict): pythran interface for the module to test.
                           Each key is the name of a function to call,
                           the value is a list of the arguments' type.
                           Special keys are 'prelude' and 'check_exception'.
  
      Returns: nothing.
  
      Raises:
         AssertionError by 'unittest' if return value differ.
         SyntaxError if code is not python valid.
         pythran.CompileError if generated code can't be compiled.
         ...possibly others...
      """
      # Extract special keys from interface.
      prelude = interface.pop("prelude", None)
      check_exception = interface.pop("check_exception", False)
      thread_count = interface.pop("thread_count", 1)
  
      assert len(interface) == 1
  
      name = next(iter(interface.keys()))
      modname = "test_" + name
  
      code = dedent(code)
  
      cxx_compiled = compile_pythrancode(
          modname,
          code,
          interface,
          extra_compile_args=self.PYTHRAN_CXX_FLAGS,
      )
  
      # FIXME Check should be done on input parameters after function call
      python_ref = self.run_python(
          code, (name, copy.deepcopy(params)), prelude, check_exception
      )
  
      run_pythran_args = (
          modname,
          cxx_compiled,
          (name, params),
          prelude,
          check_exception,
      )
      pythran_res = self.run_pythran(*run_pythran_args)
  
      if check_exception:
          if not issubclass(python_ref, pythran_res):
              raise AssertionError(
                  "expected exception was %s, but received %s"
                  % (python_ref, pythran_res)
              )
          else:
              return
  
      print("Python result: ", python_ref)
      print("Pythran result: ", pythran_res)
      harmonize_containers(python_ref)
      self.assertAlmostEqual(python_ref, pythran_res)
  
      if thread_count > 1:
          threads = [
              Thread(target=self.run_pythran, args=run_pythran_args)
              for _ in range(1, thread_count)
          ]
          for thread in threads:
              thread.start()
          for thread in threads:
              thread.join()
      self.cleanup_pythran(cxx_compiled)
  
imports: import importlib
  from numpy import float32, float64, complex128
  from numpy import intp, intc, number, bool_
  from numpy import ndarray, isnan, isinf, isneginf, complex128, complex64
  from textwrap import dedent
  from threading import Thread
  import copy
  import math
  import glob
  import numpy.testing
  import os
  import numbers
  import sys
  import unittest
  from functools import reduce
  from operator import add
  import logging
  from pythran import compile_pythrancode, spec_parser, load_specfile, frontend
  from pythran.backend import Python
  from pythran.middlend import refine
  from pythran.passmanager import PassManager
  from pythran.toolchain import _parse_optimization
  from pythran.spec import Spec
label_desc: Use image node_id 7 for calling the TestEnv obj's underlying member method code with example usage: obj.run_test(code) without return types