示例#1
0
def browser_session(*args, **kwargs):
    """A context manager that can be used to start and stop a browser.

    Usage:

        with browser_session as browser:
            # do stuff with browser here
        # Browser will be closed here

    """
    conf.env['base_url'] = kwargs['base_url']
    browser = start(*args, **kwargs)
    yield browser
    quit()
    conf.clear()
示例#2
0
def test_conf_runtime_override(random_string):
    # sanity check: If the random string is in conf.env, INSTANITY.
    assert random_string not in conf.env
    # Add the random string to the runtime dict, as well as a junk value to
    # prove we can add more than one thing via the ConfTree
    conf.runtime['env'][random_string] = True
    conf.runtime['foo'] = 'bar'
    # the override is in place
    assert random_string in conf.env
    conf.clear()
    # the override is still in place
    assert random_string in conf.env
    # deleting works
    del(conf.runtime['env'][random_string])
    assert random_string not in conf.env
示例#3
0
def browser_session(*args, **kwargs):
    """A context manager that can be used to start and stop a browser.

    Usage:

        with browser_session as browser:
            # do stuff with browser here
        # Browser will be closed here

    """
    conf.env['base_url'] = kwargs['base_url']
    browser = start(*args, **kwargs)
    try:
        yield browser
    finally:
        quit()
        conf.clear()
示例#4
0
def create_test_yaml(request, contents, filename, local=False):
    if local:
        suffix = '.local.yaml'
    else:
        suffix = '.yaml'
    filename += suffix

    confdir = request.session.fspath.join('conf')
    full_path = str(confdir.join(filename))

    test_yaml = open(full_path, 'w')
    test_yaml.write(contents)
    test_yaml.flush()
    test_yaml.seek(0)

    request.addfinalizer(lambda: os.remove(full_path))
    request.addfinalizer(lambda: conf.clear())

    return test_yaml
示例#5
0
def init():
    conf.clear()
示例#6
0
 def _clear_conf(self):
     from utils import conf
     conf.clear()
def init():
    conf.clear()
示例#8
0
def clear_conf():
    # Ensure the conf is cleared before every test
    conf.clear()