def DoTestFindPrefix(self, trie_factory):
    d = dict.fromkeys((self._SHORT_KEY, self._LONG_KEY), 42)
    t = trie_factory(self._TRIE_CLS, d)

    short_pair = (self.KeyFromKey(self._SHORT_KEY), 42)
    long_pair = (self.KeyFromKey(self._LONG_KEY), 42)
    none_pair = (None, None)

    self.assertEquals(short_pair, t.shortest_prefix(self._VERY_LONG_KEY))
    self.assertEquals(short_pair, t.shortest_prefix(self._LONG_KEY))
    self.assertEquals(short_pair, t.shortest_prefix(self._VERY_LONG_KEY))
    self.assertEquals(short_pair, t.shortest_prefix(self._LONG_PREFIXES[-1]))
    self.assertEquals(short_pair, t.shortest_prefix(self._SHORT_KEY))
    self.assertEquals(none_pair, t.shortest_prefix(self._SHORT_PREFIXES[-1]))

    self.assertEquals(long_pair, t.longest_prefix(self._VERY_LONG_KEY))
    self.assertEquals(long_pair, t.longest_prefix(self._LONG_KEY))
    self.assertEquals(long_pair, t.longest_prefix(self._VERY_LONG_KEY))
    self.assertEquals(short_pair, t.shortest_prefix(self._LONG_PREFIXES[-1]))
    self.assertEquals(short_pair, t.longest_prefix(self._SHORT_KEY))
    self.assertEquals(none_pair, t.shortest_prefix(self._SHORT_PREFIXES[-1]))

    self.assertEquals([], list(t.prefixes(self._SHORT_PREFIXES[-1])))
    self.assertEquals([short_pair], list(t.prefixes(self._SHORT_KEY)))
    self.assertEquals([short_pair], list(t.prefixes(self._LONG_PREFIXES[-1])))
    self.assertEquals([short_pair, long_pair], list(t.prefixes(self._LONG_KEY)))
    self.assertEquals([short_pair, long_pair],
                      list(t.prefixes(self._VERY_LONG_KEY)))
Prefix finding methods tests.
dataset/ETHPy150Open google/pygtrie/test.py/TrieTestCase.DoTestFindPrefix