Beispiel #1
0
def test_yaml_with_reload():
    cfg = Birch(
        NSPACE2,
        directories=[os.path.expanduser('~/.{}'.format(NSPACE2))],
        supported_formats=['yaml'],
    )
    print(cfg._val_dict)
    assert cfg['lone'] == 'puf'
    assert cfg['LONE'] == 'puf'
    lone_val = 'kakara'
    updated_valdict = copy.deepcopy(VAL_DICT2)
    updated_valdict['lone'] = lone_val
    setup_cfg_file(namespace=NSPACE2, val_dict=updated_valdict, ext='yml')
    cfg.reload()
    print(cfg._val_dict)
    assert cfg['lone'] == lone_val
    assert cfg['LONE'] == lone_val
Beispiel #2
0
def test_envvar_with_reload():
    cfg = Birch(
        NSPACE2,
        directories=[os.path.expanduser('~/.{}'.format(NSPACE2))],
        supported_formats=['yaml'],
    )
    print(cfg._val_dict)
    assert cfg['mole'] == 'geers'
    assert cfg['MOLE'] == 'geers'
    mole_envar = '{}__MOLE'.format(NSPACE2.upper())
    mole_val = 'kirgizi'
    os.environ[mole_envar] = mole_val
    cfg.reload()
    print(cfg._val_dict)
    assert cfg[mole_envar] == mole_val
    assert cfg['mole'] == mole_val
    assert cfg['MOLE'] == mole_val