def test_var_parse_missing_quotes(): var_string = """Var some_name: ( (lemma: word1) )""" with pytest.raises(ValueError): Var(var_string.split("\n"), {})
def test_var_parse_empty_ref_in_block(): var_string = """Var some_name: ( ($) )""" with pytest.raises(ValueError): Var(var_string.split("\n"), {})
def test_var_parse_bad_block(): var_string = """Var some_name: ( (bad block content) )""" with pytest.raises(ValueError): Var(var_string.split("\n"), {})
def test_var_parse_escaped_quotes(): var_string = """Var some_name: ( (lemma: \\"word1\\") ) """ with pytest.raises(ValueError): Var(var_string.split("\n"), {})
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, {})
def test_var_parse_missing_brackets(): var_string = """Var some_name: ( (lemma: "word1") lemma: "word2" ) """ with pytest.raises(ValueError): Var(var_string.split("\n"), {})
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
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
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"] == ' " '
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
def test_var_parse_bad_name(var_string): with pytest.raises(ValueError): Var(var_string.split("\n"), {})