<commit_before>###
# Tests the driver cursor API
###

import unittest
from os import getenv
from sys import path, argv
path.append("../../drivers/python")

import rethinkdb as r

num_rows = int(argv[2])
port = int(argv[1])

class TestCursor(unittest.TestCase):

    def setUp(self):
        c = r.connect(port=port)
        tbl = r.table('test')
        self.cur = tbl.run(c)

    def test_type(self):
        self.assertEqual(type(self.cur), r.Cursor)

    def test_count(self):
        i = 0
        for row in self.cur:
            i += 1

        self.assertEqual(i, num_rows)

if __name__ == '__main__':
    print "Testing cursor for %d rows" % num_rows
    suite = unittest.TestSuite()
    loader = unittest.TestLoader()
    suite.addTest(loader.loadTestsFromTestCase(TestCursor))
    unittest.TextTestRunner(verbosity=2).run(suite)<commit_msg>adds unit test for issue #650<commit_after>###
# Tests the driver cursor API
###

import unittest
from os import getenv
from sys import path, argv
path.append("../../drivers/python")

import rethinkdb as r

num_rows = int(argv[2])
port = int(argv[1])

class TestCursor(unittest.TestCase):

    def setUp(self):
        c = r.connect(port=port)
        tbl = r.table('test')
        self.cur = tbl.run(c)

    def test_type(self):
        self.assertEqual(type(self.cur), r.Cursor)

    def test_count(self):
        i = 0
        for row in self.cur:
            i += 1

        self.assertEqual(i, num_rows)

    def test_close(self):
        # This excercises a code path at the root of #650
        self.cur.close()

if __name__ == '__main__':
    print "Testing cursor for %d rows" % num_rows
    suite = unittest.TestSuite()
    loader = unittest.TestLoader()
    suite.addTest(loader.loadTestsFromTestCase(TestCursor))
    unittest.TextTestRunner(verbosity=2).run(suite)
{'fraction_non_alphanumeric': 0.1248630887185104, 'fraction_numerical': 0.008762322015334063, 'mean_word_length': 2.8955223880597014, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2959482', 'n_tokens_mistral': 617, 'n_tokens_neox': 592, 'n_words': 153}