예제 #1
0
def test_do_not_parse_multiple_configs_in_one_file():
    buf = StringIO(
        '''
base: path
---
base: other_path
name: second
nested:
    works: true
        '''
    )
    with raises(ParseError):
        parse(buf)
예제 #2
0
def test_parse_multiple_configs_in_one_file():
    buf = StringIO(u'''
base: path
---
base: other_path
name: second
nested:
    works: true
        ''')
    configs = parse(buf)
    assert isinstance(configs, list)
    assert len(configs) == 2
    assert configs[0]['base'] == 'path'
    assert configs[1]['nested'] == {'works': True}
예제 #3
0
def test_parse_multiple_configs_in_one_file():
    buf = StringIO(
        u'''
base: path
---
base: other_path
name: second
nested:
    works: true
        ''')
    configs = parse(buf)
    assert isinstance(configs, list)
    assert len(configs) == 2
    assert configs[0]['base'] == 'path'
    assert configs[1]['nested'] == {'works': True}
예제 #4
0
def test_parse_empty_value():
    buf = StringIO(u'base:')
    config = parse(buf)
    assert config[0]['base'] is None
예제 #5
0
def test_parse_null_value():
    buf = StringIO(u'base: null')
    config = parse(buf)
    assert config[0]['base'] is None
예제 #6
0
def test_parse_single_config():
    buf = StringIO(u'base: path')
    config = parse(buf)
    assert isinstance(config, list)
    assert len(config) == 1
    assert config[0]['base'] == 'path'
예제 #7
0
def test_parse_bad_type():
    buf = StringIO(u'Hello')
    with raises(ParseError):
        parse(buf)
예제 #8
0
def test_parse_invalid_yaml():
    buf = StringIO(u'- - !asdf')
    with raises(ParseError):
        parse(buf)
예제 #9
0
def test_parse_null_value():
    buf = StringIO('base: null')
    config = parse(buf)
    assert config['base'] is None
예제 #10
0
def test_parse_empty_list():
    buf = StringIO(u'base: []')
    config = parse(buf)
    assert config[0]['base'] == []
예제 #11
0
def test_parse_single_config():
    buf = StringIO(u'base: path')
    config = parse(buf)
    assert isinstance(config, list)
    assert len(config) == 1
    assert config[0]['base'] == 'path'
예제 #12
0
def test_parse_bad_type():
    buf = StringIO(u'Hello')
    with raises(ParseError):
        parse(buf)
예제 #13
0
def test_parse_invalid_yaml():
    buf = StringIO(u'- - !asdf')
    with raises(ParseError):
        parse(buf)
예제 #14
0
def test_parse_empty_string_value():
    buf = StringIO('base: ""')
    config = parse(buf)
    assert config['base'] == ''
예제 #15
0
def test_parse_empty_value():
    buf = StringIO('base:')
    config = parse(buf)
    assert config['base'] is None
예제 #16
0
def test_parse_empty_string_value():
    buf = StringIO(u'base: ""')
    config = parse(buf)
    assert config[0]['base'] == ''
예제 #17
0
def test_parse_empty_list():
    buf = StringIO(u'base: []')
    config = parse(buf)
    assert config[0]['base'] == []
예제 #18
0
def test_parse_empty_config_file():
    buf = StringIO(u'')
    with raises(ParseError):
        parse(buf)
예제 #19
0
def test_parse_empty_config_file():
    buf = StringIO(u'')
    with raises(ParseError):
        parse(buf)
예제 #20
0
def test_parse_single_config():
    buf = StringIO('base: path')
    config = parse(buf)
    assert isinstance(config, dict)
    assert config['base'] == 'path'