Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_tree_without_id(self):
tree = TokenTree(token={"form": "hej", "deprel": "nmod"}, children=[])
with self.assertRaises(ParseException):
capture_print(tree.print_tree)
def test_print_with_children(self):
tree = TokenTree(token={"id": "X", "deprel": "Y", "test": "data"}, children=[
TokenTree(token={"id": "X", "deprel": "Y", "test": "data"}, children=[]),
TokenTree(token={"id": "X", "deprel": "Y", "test": "data"}, children=[]),
])
result = capture_print(tree.print_tree)
self.assertEqual(result, dedent("""\
(deprel:Y) test:data [X]
[
"TokenTree",
"TokenTree",
"TokenTree",
]
)
self.assertEqual(
root.metadata["text"],
"The quick brown fox jumps over the lazy dog."
)
self.assertEqual(root.serialize(), data)
self.assertEqual(
capture_print(root.print_tree),
dedent("""\
(deprel:root) form:jumps lemma:jump upos:VERB [5]
def test_print_simple(self):
tree = TokenTree(token={"id": "X", "deprel": "Y", "test": "data"}, children=[])
result = capture_print(tree.print_tree)
self.assertEqual(result, "(deprel:Y) test:data [X]\n")
def test_print_empty_list(self):
tree = TokenTree(None, [])
with self.assertRaises(ParseException):
capture_print(tree.print_tree)
def test_tree_without_deprel(self):
tree = TokenTree(token={"id": 1, "form": "hej"}, children=[])
with self.assertRaises(ParseException):
capture_print(tree.print_tree)