Пример #1
0
 def testOne(self):
     """ It says yes whatever it reads. """
     rec = YesRecognizer()
     rec.consume(None)
     self.assertEqual(rec.state, RecognizerStates.YES)
     self.assertEqual(len(rec.evidence), 1)
     self.assertEqual(len(rec.info), 0)
     rec.consume(None)
     self.assertEqual(rec.state, RecognizerStates.YES)
     self.assertEqual(len(rec.evidence), 1)
     self.assertEqual(len(rec.info), 0)
Пример #2
0
    def testCopy(self):
        """ Test that the copy does not behave like the original. """
        rec = YesRecognizer()
        rec.consume(None)
        self.assertEqual(rec.state, RecognizerStates.YES)
        self.assertEqual(len(rec.evidence), 1)
        self.assertEqual(len(rec.info), 0)

        rec2 = rec.initializeNew()
        self.assertEqual(rec2.state, RecognizerStates.NO)
        self.assertEqual(len(rec2.evidence), 0)
        self.assertEqual(len(rec2.info), 0)

        self.assertEqual(rec, rec2)
        self.assertFalse(rec != YesRecognizer())