<commit_before>from django.db import connection
from django.conf import settings
from django.core.management import call_command
from django.test import TransactionTestCase

from django_tenants.utils import get_public_schema_name


class BaseTestCase(TransactionTestCase):
    """
    Base test case that comes packed with overloaded INSTALLED_APPS,
    custom public tenant, and schemas cleanup on tearDown.
    """
    @classmethod
    def setUpClass(cls):
        settings.TENANT_MODEL = 'customers.Client'
        settings.TENANT_DOMAIN_MODEL = 'customers.Domain'
        settings.SHARED_APPS = ('django_tenants',
                                'customers')
        settings.TENANT_APPS = ('dts_test_app',
                                'django.contrib.contenttypes',
                                'django.contrib.auth', )
        settings.INSTALLED_APPS = settings.SHARED_APPS + settings.TENANT_APPS

        cls.available_apps = settings.INSTALLED_APPS

        # Django calls syncdb by default for the test database, but we want
        # a blank public schema for this set of tests.
        #connection.set_schema_to_public()
        #with connection.cursor() as cursor:
        #    cursor.execute('DROP SCHEMA %s CASCADE; CREATE SCHEMA %s;'
        #                   % (get_public_schema_name(), get_public_schema_name(), ))
        super(BaseTestCase, cls).setUpClass()

    def setUp(self):
        connection.set_schema_to_public()
        super(BaseTestCase, self).setUp()

    @classmethod
    def get_tables_list_in_schema(cls, schema_name):
        cursor = connection.cursor()
        sql = """SELECT table_name FROM information_schema.tables
              WHERE table_schema = %s"""
        cursor.execute(sql, (schema_name, ))
        return [row[0] for row in cursor.fetchall()]

    @classmethod
    def sync_shared(cls):
        call_command('migrate_schemas',
                     schema_name=get_public_schema_name(),
                     interactive=False,
                     verbosity=0)
<commit_msg>Small tests cleanup<commit_after>from django.db import connection
from django.conf import settings
from django.core.management import call_command
from django.test import TransactionTestCase

from django_tenants.utils import get_public_schema_name


class BaseTestCase(TransactionTestCase):
    """
    Base test case that comes packed with overloaded INSTALLED_APPS,
    custom public tenant, and schemas cleanup on tearDown.
    """
    @classmethod
    def setUpClass(cls):
        settings.TENANT_MODEL = 'customers.Client'
        settings.TENANT_DOMAIN_MODEL = 'customers.Domain'
        settings.SHARED_APPS = ('django_tenants',
                                'customers')
        settings.TENANT_APPS = ('dts_test_app',
                                'django.contrib.contenttypes',
                                'django.contrib.auth', )
        settings.INSTALLED_APPS = settings.SHARED_APPS + settings.TENANT_APPS

        cls.available_apps = settings.INSTALLED_APPS

        super(BaseTestCase, cls).setUpClass()

    def setUp(self):
        connection.set_schema_to_public()
        super(BaseTestCase, self).setUp()

    @classmethod
    def get_tables_list_in_schema(cls, schema_name):
        cursor = connection.cursor()
        sql = """SELECT table_name FROM information_schema.tables
              WHERE table_schema = %s"""
        cursor.execute(sql, (schema_name, ))
        return [row[0] for row in cursor.fetchall()]

    @classmethod
    def sync_shared(cls):
        call_command('migrate_schemas',
                     schema_name=get_public_schema_name(),
                     interactive=False,
                     verbosity=0)

{'fraction_non_alphanumeric': 0.08245471749121384, 'fraction_numerical': 0.0010813733441470668, 'mean_word_length': 2.4741784037558685, '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': '6698291', 'n_tokens_mistral': 1038, 'n_tokens_neox': 1012, 'n_words': 225}