def ipexec_validate(fname, expected_out, expected_err='<STR_LIT>',<EOL>options=None):
import nose.tools as nt<EOL>out, err = ipexec(fname, options)<EOL>if err:<EOL><INDENT>if expected_err:<EOL><INDENT>nt.assert_equals(err.strip(), expected_err.strip())<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>' %<EOL>(fname, err))<EOL><DEDENT><DEDENT>nt.assert_equals(out.strip(), expected_out.strip())<EOL>
Utility to call 'ipython filename' and validate output/error.

    This function raises an AssertionError if the validation fails.

    Note that this starts IPython in a subprocess!

    Parameters
    ----------
    fname : str
      Name of the file to be executed (should have .py or .ipy extension).

    expected_out : str
      Expected stdout of the process.

    expected_err : optional, str
      Expected stderr of the process.

    options : optional, list
      Extra command-line flags to be passed to IPython.

    Returns
    -------
    None