예제 #1
0
 def test_reset(self):
     hack = FalloutHacker(["TEST"])
     self.assertTrue(hack.has_words())
     hack.eliminate_word("TEST", 2)
     self.assertFalse(hack.has_words())
     hack.reset()
     self.assertTrue(hack.has_words())
예제 #2
0
 def test_next(self):
     hack = FalloutHacker(["cat", "hat", "fat"])
     for i in range(3):
         word = hack.next()
         self.assertIn(word, ["CAT", "HAT", "FAT"])
         hack.next(2)
     word = hack.next()
     self.assertIsNone(word)
예제 #3
0
 def test_hack(self):
     hack = FalloutHacker([
         "dancing", "talking", "walking", "command", "pattern", "history",
         "milling", "torture", "warrior", "sealant", "tyranny", "cousins"
     ])
     target = "WARRIOR"
     word = ""
     while word != target and hack.has_words():
         word = hack.suggest_word()
         if word != target:
             hack.eliminate_word(word, self.compare(word, target))
     self.assertEqual(word, target)
예제 #4
0
 def test_suggest_word_multiple_words(self):
     hack = FalloutHacker(["TEST", "again"])
     word = hack.suggest_word()
     self.assertIn(word, ["TEST", "AGAIN"])
예제 #5
0
 def test_suggest_word_single_word(self):
     hack = FalloutHacker(["Test"])
     word = hack.suggest_word()
     self.assertEqual(word, "TEST")
예제 #6
0
 def test_eliminate_word_two_words(self):
     hack = FalloutHacker(["cat", "hat"])
     hack.eliminate_word("CAT", 2)
     word = hack.suggest_word()
     self.assertEqual(word, "HAT")