Ejemplo n.º 1
0
class TestFindWords(TestCase):

    """Tests for the find_words method."""

    def setUp(self):
        self._word_finder = WordFinder()

    def test_find_words(self):
        # Test find_words by comparing its output against a slower
        # but quite surely correct implementation of checking all the
        # permutations against the words database.
        s = "anbheiiqzmlp"
        r = 5
        gold_set = set()
        for perm in permutations(s, r):
            word = "".join(perm)
            if word in self._word_finder._word_db:
                gold_set.add(word)
        test_set = set(self._word_finder.find_words(s, r))
        self.assertSetEqual(gold_set, test_set)
Ejemplo n.º 2
0
 def setUp(self):
     self._word_finder = WordFinder()