Пример #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'