def test_create_env(): env = create_env(default_cfg) assert len(tuple(installed_options(env))) == 0 cfg = dict(default_cfg) cfg['base'] = dict(a=1, b=2) env = create_env(cfg) assert len(tuple(installed_options(env))) == 1 assert env.globals['base'].a == 1 assert env.globals['base'].b == 2
def requirements(env, requirement_name): """Check all requirements for installed options. Args: env (jinja2.Environment): requirement_name (str): type of requirement 'install', 'dvlpt' Returns: (list of str): list of required packages names """ reqs = set() for name in installed_options(env): try: opt_req = import_module("pkglts.option.%s.require" % name) reqs.update(getattr(opt_req, requirement_name)) except ImportError: raise KeyError("option '%s' does not exists" % name) return sorted(reqs)