<commit_before>
""" local-only operations
"""

from py.__.test.rsession.executor import BoxExecutor, RunExecutor
from py.__.test.rsession import report
from py.__.test.rsession.outcome import ReprOutcome

# XXX copied from session.py
def startcapture(session):
    if not session.config.option.nocapture and not session.config.option.usepdb:
        # XXX refactor integrate capturing
        from py.__.misc.simplecapture import SimpleOutErrCapture
        session._capture = SimpleOutErrCapture()

def finishcapture(session): 
    if hasattr(session, '_capture'): 
        capture = session._capture 
        del session._capture
        return capture.reset()
    return "", ""

def box_runner(item, session, reporter):
    r = BoxExecutor(item, config=session.config)
    return ReprOutcome(r.execute())

def plain_runner(item, session, reporter):
    # box executor is doing stdout/err catching for us, let's do it here
    startcapture(session)
    r = RunExecutor(item, usepdb=session.config.option.usepdb, reporter=reporter, config=session.config)
    outcome = r.execute()
    outcome = ReprOutcome(outcome.make_repr(session.config.option.tbstyle))
    outcome.stdout, outcome.stderr = finishcapture(session)
    return outcome

def benchmark_runner(item, session, reporter):
    raise NotImplementedError()

def apigen_runner(item, session, reporter):
    r = RunExecutor(item, reporter=reporter)
    session.tracer.start_tracing()
    retval = plain_runner(item, session, reporter)
    session.tracer.end_tracing()
    return retval

def exec_runner(item, session, reporter):
    raise NotImplementedError()

# runner interface is here to perform several different types of run
#+1. box_runner - for running normal boxed tests
#+2. plain_runner - for performing running without boxing (necessary for pdb)
#    XXX: really?<commit_msg>[svn r37286] Pass a config object deeper in hierarchy<commit_after>
""" local-only operations
"""

from py.__.test.rsession.executor import BoxExecutor, RunExecutor
from py.__.test.rsession import report
from py.__.test.rsession.outcome import ReprOutcome

# XXX copied from session.py
def startcapture(session):
    if not session.config.option.nocapture and not session.config.option.usepdb:
        # XXX refactor integrate capturing
        from py.__.misc.simplecapture import SimpleOutErrCapture
        session._capture = SimpleOutErrCapture()

def finishcapture(session): 
    if hasattr(session, '_capture'): 
        capture = session._capture 
        del session._capture
        return capture.reset()
    return "", ""

def box_runner(item, session, reporter):
    r = BoxExecutor(item, config=session.config)
    return ReprOutcome(r.execute())

def plain_runner(item, session, reporter):
    # box executor is doing stdout/err catching for us, let's do it here
    startcapture(session)
    r = RunExecutor(item, usepdb=session.config.option.usepdb, reporter=reporter, config=session.config)
    outcome = r.execute()
    outcome = ReprOutcome(outcome.make_repr(session.config.option.tbstyle))
    outcome.stdout, outcome.stderr = finishcapture(session)
    return outcome

def benchmark_runner(item, session, reporter):
    raise NotImplementedError()

def apigen_runner(item, session, reporter):
    r = RunExecutor(item, reporter=reporter, config=session.config)
    session.tracer.start_tracing()
    retval = plain_runner(item, session, reporter)
    session.tracer.end_tracing()
    return retval

def exec_runner(item, session, reporter):
    raise NotImplementedError()

# runner interface is here to perform several different types of run
#+1. box_runner - for running normal boxed tests
#+2. plain_runner - for performing running without boxing (necessary for pdb)
#    XXX: really?
{'fraction_non_alphanumeric': 0.09299227284838796, 'fraction_numerical': 0.002398081534772182, 'mean_word_length': 4.235704323570432, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '87872', 'n_tokens_mistral': 1073, 'n_tokens_neox': 1060, 'n_words': 302}