<commit_before>import asyncio
import random
import sys

from chilero.pg.utils import create_database, drop_database
from chilero.web.test import WebTestCase

from .application import Application


class TestCase(WebTestCase):
    application = Application
    settings = {}

    @asyncio.coroutine
    def initialize_application(self):
        return self.application(
            routes=self.routes,
            settings=self.settings,
            loop=self.loop
        )

    @classmethod
    def setUpClass(cls):
        version = '{}{}{}'.format(
            sys.version_info.major,
            sys.version_info.minor,
            sys.version_info.micro,
        )

        dyn_db_url = 'postgres://postgres@localhost/test_{version}'.format(
            version=version
        )

        db_url = '{base}_{name}_{rand}'.format(
            base=cls.settings.get('db_url') or dyn_db_url,
            name=cls.__name__,
            rand=random.randrange(1000, 100000)
        )
        cls.settings['db_url'] = db_url

        cls._database_name = db_url
        cls._initialize_db()

    @classmethod
    def tearDownClass(cls):
        cls._destroy_db()

    @classmethod
    def _initialize_db(cls):
        create_database(cls._database_name)
        if hasattr(cls, '_migrate'):
            cls._migrate(cls._database_name)

    @classmethod
    def _destroy_db(cls):
        drop_database(cls._database_name)
<commit_msg>force lowercase database names in tests<commit_after>import asyncio
import random
import sys

from chilero.pg.utils import create_database, drop_database
from chilero.web.test import WebTestCase

from .application import Application


class TestCase(WebTestCase):
    application = Application
    settings = {}

    @asyncio.coroutine
    def initialize_application(self):
        return self.application(
            routes=self.routes,
            settings=self.settings,
            loop=self.loop
        )

    @classmethod
    def setUpClass(cls):
        version = '{}{}{}'.format(
            sys.version_info.major,
            sys.version_info.minor,
            sys.version_info.micro,
        )

        dyn_db_url = 'postgres://postgres@localhost/test_{version}'.format(
            version=version
        )

        db_url = '{base}_{name}_{rand}'.format(
            base=cls.settings.get('db_url') or dyn_db_url,
            name=cls.__name__,
            rand=random.randrange(1000, 100000)
        )

        db_url = db_url.lower()

        cls.settings['db_url'] = db_url

        cls._database_name = db_url
        cls._initialize_db()

    @classmethod
    def tearDownClass(cls):
        cls._destroy_db()

    @classmethod
    def _initialize_db(cls):
        create_database(cls._database_name)
        if hasattr(cls, '_migrate'):
            cls._migrate(cls._database_name)

    @classmethod
    def _destroy_db(cls):
        drop_database(cls._database_name)

{'fraction_non_alphanumeric': 0.09787816563997262, 'fraction_numerical': 0.006844626967830253, 'mean_word_length': 2.3215909090909093, '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': '66180', 'n_tokens_mistral': 879, 'n_tokens_neox': 846, 'n_words': 151}