@@ -0,0 +1,2593 @@
+#!/usr/bin/env python%0A# -*- coding: utf-8 -*-%0A#%0A# Licensed under the GNU LGPL v2.1 - http://www.gnu.org/licenses/lgpl.html%0A%0A%22%22%22%0AAutomated tests for checking various utils functions%0A%22%22%22%0A%0A%0Aimport logging%0Aimport unittest%0A%0Afrom gensim import utils%0A%0A%0Alogging.basicConfig(format='%25(asctime)s : %25(levelname)s : %25(message)s',%0A        level=logging.WARNING)%0A%0A%0Aclass TestIsCorpus(unittest.TestCase):%0A%0A    def test_None(self):%0A        # test None%0A        print utils.isCorpus(None)%0A        result = utils.isCorpus(None)%0A        expected = (False, None)%0A        self.assertEqual(expected, result)%0A%0A    def test_simple_lists_of_tuples(self):%0A        # test list words%0A%0A        # one document, one word%0A        potentialCorpus = %5B%5B(0, 4.)%5D%5D%0A        result = utils.isCorpus(potentialCorpus)%0A        expected = (True, potentialCorpus)%0A        self.assertEqual(expected, result)%0A%0A        # one document, several words%0A        potentialCorpus = %5B%5B(0, 4.), (1, 2.)%5D%5D%0A        result = utils.isCorpus(potentialCorpus)%0A        expected = (True, potentialCorpus)%0A        self.assertEqual(expected, result)%0A%0A        potentialCorpus = %5B%5B(0, 4.), (1, 2.), (2, 5.), (3, 8.)%5D%5D%0A        result = utils.isCorpus(potentialCorpus)%0A        expected = (True, potentialCorpus)%0A        self.assertEqual(expected, result)%0A%0A        # several documents, one word%0A        potentialCorpus = %5B%5B(0, 4.)%5D, %5B(1, 2.)%5D%5D%0A        result = utils.isCorpus(potentialCorpus)%0A        expected = (True, potentialCorpus)%0A        self.assertEqual(expected, result)%0A%0A        potentialCorpus = %5B%5B(0, 4.)%5D, %5B(1, 2.)%5D, %5B(2, 5.)%5D, %5B(3, 8.)%5D%5D%0A        result = utils.isCorpus(potentialCorpus)%0A        expected = (True, potentialCorpus)%0A        self.assertEqual(expected, result)%0A%0A    def test_int_tuples(self):%0A        potentialCorpus = %5B%5B(0, 4)%5D%5D%0A        result = utils.isCorpus(potentialCorpus)%0A        expected = (True, potentialCorpus)%0A        self.assertEqual(expected, result)%0A%0A    def test_invalid_formats(self):%0A        # test invalid formats%0A        # these are no corpus, because they do not consists of 2-tuples with%0A        # the form(int, float).%0A        potentials = list()%0A        potentials.append(%5B%22human%22%5D)%0A        potentials.append(%22human%22)%0A        potentials.append(%5B%22human%22, %22star%22%5D)%0A        potentials.append(%5B1, 2, 3, 4, 5, 5%5D)%0A        potentials.append(%5B%5B(0, 'string')%5D%5D)%0A        for noCorpus in potentials:%0A            result = utils.isCorpus(noCorpus)%0A            expected = (False, noCorpus)%0A            self.assertEqual(expected, result)%0A%0A%0Aif __name__ == '__main__':%0A    logging.root.setLevel(logging.WARNING)%0A    unittest.main()%0A

Add tests for isCorpus() in utils.py.