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()
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
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()
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
def init(): conf.clear()
def _clear_conf(self): from utils import conf conf.clear()
def clear_conf(): # Ensure the conf is cleared before every test conf.clear()