<commit_before>import os
import json
import tornado_mysql
import unittest

from tornado import gen
from tornado.testing import AsyncTestCase, gen_test


class PyMySQLTestCase(AsyncTestCase):
    # You can specify your test environment creating a file named
    #  "databases.json" or editing the `databases` variable below.
    fname = os.path.join(os.path.dirname(__file__), "databases.json")
    if os.path.exists(fname):
        with open(fname) as f:
            databases = json.load(f)
    else:
        databases = [
            {"host":"localhost","user":"root",
             "passwd":"","db":"test_pymysql", "use_unicode": True},
            {"host":"localhost","user":"root","passwd":"","db":"test_pymysql2"}]

    @gen.coroutine
    def _connect_all(self):
        for params in self.databases:
            conn = yield tornado_mysql.connect(**params)
            self.connections.append(conn)

    def setUp(self):
        super(PyMySQLTestCase, self).setUp()
        self.connections = []
        self.io_loop.run_sync(self._connect_all)

    def tearDown(self):
        for connection in self.connections:
            connection.close()<commit_msg>Fix unclosed file warning<commit_after>import os
import json
import tornado_mysql
import unittest

from tornado import gen
from tornado.testing import AsyncTestCase, gen_test


class PyMySQLTestCase(AsyncTestCase):
    # You can specify your test environment creating a file named
    #  "databases.json" or editing the `databases` variable below.
    fname = os.path.join(os.path.dirname(__file__), "databases.json")
    if os.path.exists(fname):
        with open(fname) as f:
            databases = json.load(f)
    else:
        databases = [
            {"host":"localhost","user":"root",
             "passwd":"","db":"test_pymysql", "use_unicode": True},
            {"host":"localhost","user":"root","passwd":"","db":"test_pymysql2"}]

    @gen.coroutine
    def _connect_all(self):
        for params in self.databases:
            conn = yield tornado_mysql.connect(io_loop=self.io_loop, **params)
            self.connections.append(conn)

    def setUp(self):
        super(PyMySQLTestCase, self).setUp()
        self.connections = []
        self.io_loop.run_sync(self._connect_all)

    def tearDown(self):
        for connection in self.connections:
            connection.close()
        super(PyMySQLTestCase, self).tearDown()
{'fraction_non_alphanumeric': 0.12261014131338321, 'fraction_numerical': 0.0008312551953449709, 'mean_word_length': 2.9917081260364844, 'pattern_counts': {'":': 18, '<': 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': '4411871', 'n_tokens_mistral': 724, 'n_tokens_neox': 700, 'n_words': 161}