class TrieTest(unittest.TestCase): def __init__(self, *args, **kwargs): from greekutils.trie import Trie super(TrieTest, self).__init__(*args, **kwargs) self.t = Trie() def test_1(self): self.t.add("foo", "bar") self.assertEqual(self.t.find_prefix("fo"), ("", None, "fo")) self.assertEqual(self.t.find_prefix("foo"), ("foo", "bar", "")) self.assertEqual(self.t.find_prefix("food"), ("foo", "bar", "d")) def test_2(self): self.t.add("a", "yes") self.t.add("abc", "yes") self.assertEqual(self.t.find_prefix("abdc"), ("a", "yes", "bdc"))
def __init__(self, *args, **kwargs): from greekutils.trie import Trie super(TrieTest, self).__init__(*args, **kwargs) self.t = Trie()