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}
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)
def test_parse_null_value():
    buf = StringIO('base: null')
    config = parse(buf)
    assert config['base'] is None
def test_parse_empty_list():
    buf = StringIO(u'base: []')
    config = parse(buf)
    assert config[0]['base'] == []
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'
def test_parse_bad_type():
    buf = StringIO(u'Hello')
    with raises(ParseError):
        parse(buf)
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'] == []
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'