Beispiel #1
0
 def test_path_readonly(self):
     with self.assertRaises(AttributeError):
         n = trie.Node()
         n.path = 'a'
Beispiel #2
0
 def test_slots(self):
     with self.assertRaises(AttributeError):
         n = trie.Node()
         n.data = None
Beispiel #3
0
 def test_len(self):
     keys = [(k, Ellipsis) for k in range(128, 256)]
     n = trie.Node()
     for k, v in keys:
         n[k] = v
     self.assertEqual(len(n), 128)
Beispiel #4
0
 def test_set_path(self):
     n = trie.Node('a')
     self.assertEqual(n.path, 'a')
Beispiel #5
0
 def test_iterate(self):
     keys = [(k, Ellipsis) for k in range(128, 256)]
     n = trie.Node()
     for k, v in keys:
         n[k] = v
     self.assertSequenceEqual(list(iter(n)), keys)
Beispiel #6
0
 def test_contains(self):
     n = trie.Node()
     self.assertFalse(0 in n)
     n[0] = Ellipsis
     self.assertTrue(0 in n)
Beispiel #7
0
 def test_set_set(self):
     n = trie.Node()
     n[0] = False
     self.assertIs(n[0], False)
     n[0] = True
     self.assertIs(n[0], True)
Beispiel #8
0
 def test_set_del(self):
     n = trie.Node()
     n[0] = Ellipsis
     del n[0]
     self.assertIs(n[0], None)
Beispiel #9
0
 def test_set_get(self):
     n = trie.Node()
     n[0] = Ellipsis
     self.assertIs(n[0], Ellipsis)