<commit_before>from django.core.management import call_command
from django.test.utils import get_runner
from django.conf import settings
from django.db import connections, DEFAULT_DB_ALIAS


# use jenkins runner if present otherwise the default django one
if 'django_jenkins' in settings.INSTALLED_APPS:
    base_runner = 'django_jenkins.runner.CITestSuiteRunner'
else:
    base_runner = 'django.test.runner.DiscoverRunner'


class CLADiscoverRunner(get_runner(settings, base_runner)):
    """
    Overrides the default Runner and loads the initial_groups fixture.
    This is because migrations are switched off during testing but
    we do need `initial_groups` in order for the tests to pass.
    """
    def setup_databases(self, **kwargs):
        ret = super(CLADiscoverRunner, self).setup_databases(**kwargs)
        connection = connections[DEFAULT_DB_ALIAS]
        cursor = connection.cursor()
        cursor.execute('CREATE EXTENSION pgcrypto')
        call_command('loaddata', 'initial_groups')
        return ret<commit_msg>Install pgcrypto PGSQL extension but only if it does not exist already (e.g. from template1)<commit_after>from django.core.management import call_command
from django.test.utils import get_runner
from django.conf import settings
from django.db import connections, DEFAULT_DB_ALIAS


# use jenkins runner if present otherwise the default django one
if 'django_jenkins' in settings.INSTALLED_APPS:
    base_runner = 'django_jenkins.runner.CITestSuiteRunner'
else:
    base_runner = 'django.test.runner.DiscoverRunner'


class CLADiscoverRunner(get_runner(settings, base_runner)):
    """
    Overrides the default Runner and loads the initial_groups fixture.
    This is because migrations are switched off during testing but
    we do need `initial_groups` in order for the tests to pass.
    """
    def setup_databases(self, **kwargs):
        ret = super(CLADiscoverRunner, self).setup_databases(**kwargs)
        connection = connections[DEFAULT_DB_ALIAS]
        cursor = connection.cursor()
        cursor.execute('CREATE EXTENSION IF NOT EXISTS pgcrypto')
        call_command('loaddata', 'initial_groups')
        return ret
{'fraction_non_alphanumeric': 0.07291185971389016, 'fraction_numerical': 0.00046146746654360867, 'mean_word_length': 4.313725490196078, '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': '7464517', 'n_tokens_mistral': 605, 'n_tokens_neox': 592, 'n_words': 188}