def run_scenario(application=None, feature=None, scenario=None, **opts):
if '<STR_LIT>' in sys.modules:<EOL><INDENT>rcfile = os.path.join(BASE_DIR, '<STR_LIT>')<EOL>args = ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', rcfile]<EOL><DEDENT>else:<EOL><INDENT>args = ['<STR_LIT>']<EOL><DEDENT>args += ['<STR_LIT>', '<STR_LIT>']<EOL>if feature:<EOL><INDENT>feature = '<STR_LIT>'.format(feature)<EOL><DEDENT>if application:<EOL><INDENT>if feature:<EOL><INDENT>args.append('<STR_LIT>'.format(application, feature))<EOL><DEDENT>else:<EOL><INDENT>args.append(application)<EOL><DEDENT><DEDENT>if scenario:<EOL><INDENT>opts['<STR_LIT:n>'] = scenario<EOL><DEDENT>opts.setdefault('<STR_LIT:v>', <NUM_LIT:3>)<EOL>for opt, val in opts.items():<EOL><INDENT>if len(opt) == <NUM_LIT:1>:<EOL><INDENT>args.append('<STR_LIT>'.format(opt))<EOL>if val:<EOL><INDENT>args.append(str(val))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if val:<EOL><INDENT>args.append('<STR_LIT>'.format(opt, val))<EOL><DEDENT>else:<EOL><INDENT>args.append('<STR_LIT>'.format(opt))<EOL><DEDENT><DEDENT><DEDENT>proc = subprocess.Popen(<EOL>args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)<EOL>text, _ = proc.communicate()<EOL>text = text.decode('<STR_LIT:utf-8>').rstrip()<EOL>return proc.returncode, text<EOL>
Run a scenario and return the exit code and output.

:param application: The application module to run the features in
:param feature: The feature to run (without extension)
:param scenario: The scenario index to run
:param opts: Additional options to harvest. Single-letter options are
prefixed with a dash, long options are formatted as --option=value.