25 lines
610 B
Python
25 lines
610 B
Python
|
|
import pytest
|
|
|
|
from xbc import loads_xbc, ParseError
|
|
|
|
def test_empty():
|
|
assert loads_xbc('a {}') == {'a': True}
|
|
|
|
def test_keyvalue():
|
|
assert loads_xbc('a { a = 1 }') == {'a': False, 'a.a': '1'}
|
|
|
|
def test_nested_block():
|
|
assert loads_xbc('a { b { c = 1 } }') == {'a.b.c': '1', 'a': False, 'a.b': False}
|
|
|
|
def test_keyvalue_and_block():
|
|
assert loads_xbc('a = 1\na { a = 1 }') == {'a': False, 'a': '1', 'a.a': '1'}
|
|
|
|
def test_reassign_colon():
|
|
with pytest.raises(ParseError):
|
|
loads_xbc('a { a = 1; a = 2 }')
|
|
|
|
def test_assign_after_block():
|
|
with pytest.raises(ParseError):
|
|
loads_xbc('a { a = 1 }\na = 1')
|