Ejemplo n.º 1
0
def test_var_parse_missing_quotes():
    var_string = """Var some_name:
(
    (lemma: word1)
)"""
    with pytest.raises(ValueError):
        Var(var_string.split("\n"), {})
Ejemplo n.º 2
0
def test_var_parse_empty_ref_in_block():
    var_string = """Var some_name:
(
    ($)
)"""
    with pytest.raises(ValueError):
        Var(var_string.split("\n"), {})
Ejemplo n.º 3
0
def test_var_parse_bad_block():
    var_string = """Var some_name:
(
    (bad block content)
)"""
    with pytest.raises(ValueError):
        Var(var_string.split("\n"), {})
Ejemplo n.º 4
0
def test_var_parse_escaped_quotes():
    var_string = """Var some_name:
(
    (lemma: \\"word1\\")
)
"""
    with pytest.raises(ValueError):
        Var(var_string.split("\n"), {})
Ejemplo n.º 5
0
def test_var_parse_att_unescaped_quote():
    var_string = """Var some_name:
(
    (att: " " ")
)"""
    with pytest.raises(ValueError):
        lines = [(s, -1) for s in var_string.split("\n")]
        Var(lines, {})
Ejemplo n.º 6
0
def test_var_parse_missing_brackets():
    var_string = """Var some_name:
(
    (lemma: "word1")
    lemma: "word2"
)
"""
    with pytest.raises(ValueError):
        Var(var_string.split("\n"), {})
Ejemplo n.º 7
0
def test_var_parse_empty():
    var_string = """Var some_name:
(
    ( (   ) )
)"""
    lines = [(s, -1) for s in var_string.split("\n")]
    var = Var(lines, {})
    assert var.name == "some_name"
    assert len(var.body.members) == 0
    assert var.body.union is False
Ejemplo n.º 8
0
def test_var_parse():
    var_string = """Var some_name:
(
    (lemma: \"word1\")
    (lemma: \"word2\")
)"""
    lines = [(s, -1) for s in var_string.split("\n")]
    var = Var(lines, {})
    assert var.name == "some_name"
    assert len(var.body.members) == 2
    assert var.body.union is False
Ejemplo n.º 9
0
def test_var_parse_att_escaped_quote():
    var_string = """Var some_name:
(
    (att: " \\" ")
)"""
    lines = [(s, -1) for s in var_string.split("\n")]
    var = Var(lines, {})
    assert var.name == "some_name"
    assert len(var.body.members) == 1
    assert var.body.union is False
    assert var.body.members[0].atts["att"] == ' " '
Ejemplo n.º 10
0
def test_var_parse_att_quoted_brackets():
    var_string = """Var some_name:
(
    (att: " ) ")
    (att: " ( ")
    (att: " ())( ")
    (att: " )))))))))))))))) ")
)"""
    vals = [" ) ", " ( ", " ())( ", " )))))))))))))))) "]
    lines = [(s, -1) for s in var_string.split("\n")]
    var = Var(lines, {})
    assert var.name == "some_name"
    assert len(var.body.members) == 4
    assert var.body.union is False
    for m, v in zip(var.body.members, vals):
        assert m.atts["att"] == v
Ejemplo n.º 11
0
def test_var_parse_bad_name(var_string):
    with pytest.raises(ValueError):
        Var(var_string.split("\n"), {})