def test_line_reading(self): a = "Plastikowe fiolki zakwitly na zime." b = "Poczytaj Schopenhauera" line = "Plastikowe fiolki \\\nzakwitly na zime.! serio \nPoczytaj Schopenhauera" x = OboIterator(StringIO(line)) self.assertEqual(a, x._read_line()) self.assertEqual(b, x._read_line()) self.assertEqual(None, x._read_line())
def test_wrong_tag(self): a = """ [Term] id : a is_a """ with self.assertRaises(ValueError): list(OboIterator(StringIO(a)))
def test_simple_terms(self): a = """ format-version: 1.2 data-version: 2013-05-04 saved-by: kamil [Term] id : a is_a : b [Typedef] id: y name: x [Term] id : b \\ aha is_a : c is_a : d [Typedef] id: x name: y """ x = list(OboIterator(StringIO(a))) expected = [("Term", { "id": ["a"], "is_a": ["b"] }), ("Typedef", { "id": ["y"], "name": ["x"] }), ("Term", { "id": ["b aha"], "is_a": ["c", "d"] }), ("Typedef", { "id": ["x"], "name": ["y"] })] self.assertEqual(expected, x)
def test_strip_comment(self): a = "plastikowe fiolki " b = a + "! zakwitly ! " x = OboIterator(None) self.assertEqual(a, x._strip_comment(b))