def setup(): global _ENV_SETUP if _ENV_SETUP: return for key, (default, validate, convert, detype, docstr) in ENVVARS.items(): if key in ENV: del ENV[key] ENV._defaults[key] = default() if callable(default) else default ENV._ensurers[key] = Ensurer(validate=validate, convert=convert, detype=detype) ENV._docs[key] = VarDocs(docstr=docstr) _ENV_SETUP = True
def setup(): global _ENV_SETUP if _ENV_SETUP: return env = builtins.__xonsh_env__ updates = {} for key, (default, validate, convert, detype, docstr) in ENVVARS.items(): if key in env: updates[key] = env.pop(key) env._defaults[key] = default() if callable(default) else default env._ensurers[key] = Ensurer(validate=validate, convert=convert, detype=detype) env._docs[key] = VarDocs(docstr=docstr) env.update(updates) _ENV_SETUP = True
def test_env_detype_no_dict(): env = Env(YO={"hey": 42}) env.set_ensurer("YO", Ensurer(always_true, None, None)) det = env.detype() assert "YO" not in det