import pytest from xbc import loads_xbc, ParseError def test_key(): assert loads_xbc('a') == {'a': True} def test_dot_key(): assert loads_xbc('a.a') == {'a.a': True} def test_key_eq(): assert loads_xbc('a =') == {'a': True} def test_keyvalue(): assert loads_xbc('a = 1') == {'a': '1'} def test_keyvalue_space(): assert loads_xbc('a = a b') == {'a': 'a b'} def test_dot_keyvalue(): assert loads_xbc('a.a = 1') == {'a': False, 'a.a': '1'} def test_keys(): assert loads_xbc('a;b') == {'a': True, 'b': True} def test_dot_keys(): assert loads_xbc('a.a;a.b') == {'a.a': True, 'a.b': True} def test_quoted(): assert loads_xbc('a = "b"') == {'a': 'b'} def test_quoted_space(): assert loads_xbc('a = "b "') == {'a': 'b '} def test_array(): assert loads_xbc('a = 1, 2') == {'a': ['1', '2']} def test_reassignment(): with pytest.raises(ParseError): loads_xbc('a = 1\na = 2') def test_reassignment_colon(): with pytest.raises(ParseError): loads_xbc('a = 1;a = 2') def test_ovewrite_nonexistent(): with pytest.raises(ParseError): loads_xbc('a := 1')