def run(*arg, **kw):
from nose import run<EOL>from nose.config import Config<EOL>from nose.plugins.manager import PluginManager<EOL>buffer = Buffer()<EOL>if '<STR_LIT>' not in kw:<EOL><INDENT>plugins = kw.pop('<STR_LIT>', [])<EOL>if isinstance(plugins, list):<EOL><INDENT>plugins = PluginManager(plugins=plugins)<EOL><DEDENT>env = kw.pop('<STR_LIT>', {})<EOL>kw['<STR_LIT>'] = Config(env=env, plugins=plugins)<EOL><DEDENT>if '<STR_LIT>' not in kw:<EOL><INDENT>kw['<STR_LIT>'] = ['<STR_LIT>', '<STR_LIT>']<EOL><DEDENT>kw['<STR_LIT>'].stream = buffer<EOL>stderr = sys.stderr<EOL>stdout = sys.stdout<EOL>if kw.pop('<STR_LIT>', False):<EOL><INDENT>sys.stdout = sys.stderr = buffer<EOL>restore = True<EOL><DEDENT>else:<EOL><INDENT>restore = False<EOL>warn("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>",<EOL>DeprecationWarning, stacklevel=<NUM_LIT:2>)<EOL><DEDENT>try:<EOL><INDENT>run(*arg, **kw)<EOL><DEDENT>finally:<EOL><INDENT>if restore:<EOL><INDENT>sys.stderr = stderr<EOL>sys.stdout = stdout<EOL><DEDENT><DEDENT>out = buffer.getvalue()<EOL>print(munge_nose_output_for_doctest(out))<EOL>
Specialized version of nose.run for use inside of doctests that
test test runs.

This version of run() prints the result output to stdout.  Before
printing, the output is processed by replacing the timing
information with an ellipsis (...), removing traceback stacks, and
removing trailing whitespace.

Use this version of run wherever you are writing a doctest that
tests nose (or unittest) test result output.

Note: do not use doctest: +ELLIPSIS when testing nose output,
since ellipses ("test_foo ... ok") in your expected test runner
output may match multiple lines of output, causing spurious test
passes!