示例#1
0
def fxcfg():
    import tempfile
    tdir = tempfile.gettempdir()
    cfg = os.path.join(tdir, '_cfg_')
    bcfg = os.path.join(tdir, '_bcfg_')
    # remove previous configs
    if os.path.isfile(cfg):
        os.remove(cfg)
    if os.path.isfile(bcfg):
        os.remove(bcfg)
    # write content
    with open(cfg, 'wt') as cfgf:
        cfgf.write('''
base_cfg: {}
val1: 1
val2: 2
env1: $WZDAT_CFG/test_cfg
'''.format(bcfg))
    with open(bcfg, 'wt') as bcfgf:
        bcfgf.write('''
val0: 0
val2: -1
env0: $WZDAT_CFG/test_bcfg
''')
    yield cfg
    os.remove(cfg)
    os.remove(bcfg)
    invalidate_config()
示例#2
0
def test_common_config(fxcfg):
    invalidate_config()
    cfg = make_config(fxcfg)
    assert type(cfg) == dict
    assert cfg['val0'] == 0
    assert cfg['val1'] == 1
    assert cfg['val2'] == 2
    cp = os.environ['WZDAT_CFG']
    cfgenv0 = os.path.join(cp, 'test_bcfg')
    cfgenv1 = os.path.join(cp, 'test_cfg')
    assert cfg['env0'] == cfgenv0
    assert cfg['env1'] == cfgenv1