def testHasSizeWords(self): chain = w.markov_chain("I am red and blue", 2) output = w.chain_to_text(chain, 20) self.assertEqual(len(output), 20)
def testDoesNotBreakIfNoMatchingPrefix(self): chain = w.markov_chain("I", 2) output = w.chain_to_text(chain, 200)
def testTurnsChainsToText(self): chain = w.markov_chain("I am red and blue", 2) output = w.chain_to_text(chain, 1) self.assertEqual(output[0], "I")
def testUsesSizeOfDict(self): chain = w.markov_chain("I am red", 3) output = w.chain_to_text(chain, 3) self.assertEqual(output, ['I', 'am', 'red'])
def testUsesRandomSample(self): chain = w.markov_chain("I am red I am blue", 2) output = w.chain_to_text(chain, 30) self.assertIn('red', output) self.assertIn('blue', output)
def testUsesMostRecentWords(self): chain = w.markov_chain("I am red", 2) output = w.chain_to_text(chain, 3) self.assertEqual(output, ['I', 'am', 'red'])