py-xbc/tests/test_block.py

25 lines
610 B
Python
Raw Normal View History

2024-01-13 06:44:43 +00:00
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'}
2024-01-13 06:44:43 +00:00
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')