Exemplo n.º 1
0
def test_load_config(mock_file):
    mock_file('default.ini',
              dedent('''
        [section]
        key: value
    '''))
    env = environment.Environment('default')
    assert env['section']['key'] == 'value'
Exemplo n.º 2
0
def test_default_section_not_in_sections(mock_file):
    mock_file(
        'default.ini',
        dedent('''
        [DEFAULT]
        default_key: default_value

        [section]
        key: value
    '''))
    env = environment.Environment('default')
    assert env.sections() == ['section']
Exemplo n.º 3
0
def test_load_multiple_sections(mock_file):
    mock_file(
        'default.ini',
        dedent('''
        [DEFAULT]
        default_key: default_value

        [section]
        key: value
    '''))
    env = environment.Environment('default')
    assert env['section']['key'] == 'value'
    assert env['DEFAULT']['default_key'] == 'default_value'
Exemplo n.º 4
0
def test_interpolation(mock_file):
    mock_file(
        'default.ini',
        dedent('''
        [DEFAULT]
        url: localhost
        sub_url: ${url}/sub_url

        [section]
        section_url: ${DEFAULT:url}/section_url
    '''))
    env = environment.Environment('default')
    assert env['DEFAULT']['sub_url'] == 'localhost/sub_url'
    assert env['section']['section_url'] == 'localhost/section_url'
Exemplo n.º 5
0
def test_load_empty_config_doesnt_fail(mock_file):
    mock_file('default.ini', '')
    env = environment.Environment('default')