Ejemplo n.º 1
0
def exec_file(filename, globals=None, locals=None):
    if globals is None:
        globals = {}
    if locals is None:
        locals = globals
    locals['__file__'] = filename
    from py import path
    from _pytest import config
    from _pytest.assertion import rewrite
    f = path.local(filename)
    filename2 = os.path.relpath(filename, os.getcwd())
    config = config._prepareconfig([], [])
    _, code = rewrite._rewrite_test(config, f)
    exec(code, globals, locals)
def exec_file(filename, globals=None, locals=None):
    """Execute the specified file, optionaly setup its context by using globals and locals."""
    if globals is None:
        globals = {}
    if locals is None:
        locals = globals
    locals['__file__'] = filename
    from py import path
    from _pytest import config
    from _pytest.assertion import rewrite
    f = path.local(filename)
    filename2 = os.path.relpath(filename, os.getcwd())
    config = config._prepareconfig([], [])
    _, code = rewrite._rewrite_test(config, f)
    exec(code, globals, locals)
Ejemplo n.º 3
0
def exec_file(filename, globals=None, locals=None):
    """Execute the specified file, optionaly setup its context by using globals and locals."""
    if globals is None:
        globals = {}
    if locals is None:
        locals = globals
    locals['__file__'] = filename
    from py import path
    from _pytest import config
    from _pytest.assertion import rewrite
    f = path.local(filename)
    config = config._prepareconfig([], [])
    source_stat, code = rewrite._rewrite_test(config, f)
    logger.debug('filename: {} source_stat: {} code: {}'.format(filename, source_stat, code))
    exec(code, globals, locals)