Example #1
0
def test_builder_methods():
    c = Config()
    c.option('option1', 1)
    assert c.section is None
    assert c['option1'] is 1
    c.section = 'SECTION1'
    c.option('option2', 2)
    opt = c.get_option('option2', 'SECTION1')
    assert opt.section == 'SECTION1'
Example #2
0
def test_cache():
    os.environ['OPTION2'] = '33'
    os.environ['OPTION3'] = 'spam'

    config = Config(options=[
        Option('option1', 1),
        Option('User'),
        Option('ForwardX11'),
        Option('Port'),
    ],
                    readers=[
                        EnvConfigReader(),
                        IniConfigReader(
                            'tests/config.ini',
                            sections=['bitbucket.org', 'topsecret.server.com'])
                    ])

    config.section = "OTHER"
    config.option('option4', 'yes')