def testPrefixSet(self):
    ps = pygtrie.PrefixSet(factory=self._TRIE_CLS)

    short_key = self.KeyFromKey(self._SHORT_KEY)
    long_key = self.KeyFromKey(self._LONG_KEY)
    very_long_key = self.KeyFromKey(self._VERY_LONG_KEY)
    other_key = self.KeyFromKey(self._OTHER_KEY)

    for key in (self._LONG_KEY, self._VERY_LONG_KEY):
      ps.add(key)
      self.assertEquals(1, len(ps))
      self.assertEquals([long_key], list(ps.iter()))
      self.assertEquals([long_key], list(iter(ps)))
      self.assertEquals([long_key], list(ps.iter(self._SHORT_KEY)))
      self.assertEquals([long_key], list(ps.iter(self._LONG_KEY)))
      self.assertEquals([very_long_key], list(ps.iter(self._VERY_LONG_KEY)))
      self.assertEquals([], list(ps.iter(self._OTHER_KEY)))

    ps.add(self._SHORT_KEY)
    self.assertEquals(1, len(ps))
    self.assertEquals([short_key], list(ps.iter()))
    self.assertEquals([short_key], list(iter(ps)))
    self.assertEquals([short_key], list(ps.iter(self._SHORT_KEY)))
    self.assertEquals([long_key], list(ps.iter(self._LONG_KEY)))
    self.assertEquals([], list(ps.iter(self._OTHER_KEY)))

    ps.add(self._OTHER_KEY)
    self.assertEquals(2, len(ps))
    self.assertEquals(sorted((short_key, other_key)),
                      list(ps.iter()))
    self.assertEquals([short_key], list(ps.iter(self._SHORT_KEY)))
    self.assertEquals([long_key], list(ps.iter(self._LONG_KEY)))
    self.assertEquals([other_key], list(ps.iter(self._OTHER_KEY)))
Start an instance.
dataset/ETHPy150Open google/pygtrie/test.py/TrieTestCase.testPrefixSet--crossover with--dataset/ETHPy150Open ganeti/ganeti/lib/hypervisor/hv_chroot.py/ChrootManager.StartInstance