from itertools import izip, cycle

from unittest import TestCase


class TestClassifierBase(TestCase):

    def _training(self, classification_type, classifier, alphabet,
                  reversed_alphabet):
        reversed_alphabet = reversed(alphabet)
        messagePairs = izip(alphabet, reversed_alphabet)
        for message, is_spam in izip(messagePairs, cycle((True, False))):
            classifier.train(classification_type, message, is_spam)

Add a base class for certain types of tests
Add a base class for certain types of tests

This is so training data can be reused across classes.
In fact nonsensefilter's test have been using this for quite some time
but this was not committed. Oops!
