def test_add_existing_WordShouldReplaceAssociatedValue(self):
        t = Trie()
        t.add('python', 'value')
        assert ('python', 'value') == t.get('python')

        t.add('python', 'other')
        assert ('python', 'other') == t.get('python')
示例#2
0
    def testAddingExistingWordShouldReplaceAssociatedValue(self):
        t = Trie()
        t.add('python', 'value')
        assert Output('python', 'value') == t.get('python')

        t.add('python', 'other')
        assert Output('python', 'other') == t.get('python')
 def test_get_UnknowWordWithDefaultValueShouldReturnDefault(self):
     t = Trie()
     self.assertEqual(t.get('python', 'default'), 'default')
 def test_get_UnknowWordWithoutDefaultValueShouldRaiseException(self):
     t = Trie()
     with self.assertRaises(KeyError):
         t.get('python')
 def test_add_can_get(self):
     t = Trie()
     t.add('python', 'value')
     assert ('python', 'value') == t.get('python')
示例#6
0
 def testAddedWordShouldBeCountedAndAvailableForRetrieval(self):
     t = Trie()
     t.add('python', 'value')
     assert Output('python', 'value') == t.get('python')