class_docstr: Test environment to validate a pythran execution against python. 
class_docstr_tok: ["Test","environment","to","validate","a","pythran","execution","against","python","."]
docstr: Check if a final node is the same as expected.
  
  Parameters
  ----------
  code : str
      code we want to check after refine and optimizations
  ref : str
      The expected dump for the AST
  optimizations : [optimization]
      list of optimisation to apply
  
  Raises
  ------
  is_same : AssertionError
      Raise if the result is not the one expected.
docstr_tok: ["Check","if","a","final","node","is","the","same","as","expected",".","Parameters","--","--","--","--","--","code",":","str","code","we","want","to","check","after","refine","and","optimizations","ref",":","str","The","expected","dump","for","the","AST","optimizations",":","[","optimization","]","list","of","optimisation","to","apply","Raises","--","--","--","is_same",":","AssertionError","Raise","if","the","result","is","not","the","one","expected","."]
code: def check_ast(code, ref, optimizations):
      """
      Check if a final node is the same as expected.
  
      Parameters
      ----------
      code : str
          code we want to check after refine and optimizations
      ref : str
          The expected dump for the AST
      optimizations : [optimization]
          list of optimisation to apply
  
      Raises
      ------
      is_same : AssertionError
          Raise if the result is not the one expected.
      """
      pm = PassManager("testing")
  
      ir, _ = frontend.parse(pm, dedent(code))
  
      optimizations = [
          _parse_optimization(opt) for opt in optimizations
      ]
      refine(pm, ir, optimizations)
  
      content = pm.dump(Python, ir)
  
      if content != dedent(ref).strip():
          raise AssertionError(
              "AST is not the one expected. Reference was %s,"
              "but received %s"
              % (repr(dedent(ref).strip()), repr(content))
          )
  
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 8 for calling the TestEnv obj's underlying member method code with example usage: obj.check_ast(code, ref, optimizations) without return types