def testOne(self):
     """ Should behave just like the yes recognizer. """
     rec = ManyRecognizer(1)
     self.assertEqual(rec.state, RecognizerStates.NO)
     rec.consume(None)
     self.assertEqual(rec.state, RecognizerStates.YES)
     self.assertEqual(len(rec.evidence), 1)
 def testZero(self):
     """ If zero are enough it should be in yes state already. """
     rec = ManyRecognizer(0)
     self.assertEqual(rec.state, RecognizerStates.YES)
     self.assertEqual(rec.evidence, [])
     rec.consume(None)
     self.assertEqual(rec.state, RecognizerStates.YES)
     self.assertEqual(rec.evidence, [])
 def testTwo(self):
     """ If two are required it should pass through the maybe state. """
     rec = ManyRecognizer(2)
     self.assertEqual(rec.state, RecognizerStates.NO)
     rec.consume(None)
     self.assertEqual(rec.state, RecognizerStates.MAYBE_NO)
     self.assertEqual(len(rec.evidence), 1)
     rec.consume(None)
     self.assertEqual(rec.state, RecognizerStates.YES)
     self.assertEqual(len(rec.evidence), 2)
    def testCopy(self):
        """ Test copying. """
        rec = ManyRecognizer(1)
        self.assertEqual(rec.state, RecognizerStates.NO)
        rec.consume(None)
        self.assertEqual(rec.state, RecognizerStates.YES)
        self.assertEqual(len(rec.evidence), 1)

        rec2 = rec.initializeNew()
        self.assertEqual(rec2.state, RecognizerStates.NO)

        self.assertEqual(rec, rec2)
        self.assertNotEqual(rec, ManyRecognizer(2))