<commit_before>#!/usr/bin/env python
import os
import sys

from django.conf import settings

try:
    import social_auth
except ImportError:
    social_auth = None

SWAPPED = os.environ.get('SWAPPED', False)

INSTALLED_APPS = [
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.admin',
    'south',
    'allaccess',
]

if social_auth is not None:
    INSTALLED_APPS.append('social_auth')

if not settings.configured:
    settings.configure(
        DATABASES={
            'default': {
                'ENGINE': 'django.db.backends.sqlite3',
                'NAME': ':memory:',
            }
        },
        INSTALLED_APPS=INSTALLED_APPS,
        AUTHENTICATION_BACKENDS=(
            'allaccess.backends.AuthorizedServiceBackend',
        ),
        SITE_ID=1,
        SECRET_KEY='<KEY>',
        ROOT_URLCONF='allaccess.tests.urls',
        LOGIN_URL='/login/',
        LOGIN_REDIRECT_URL='/',
        USE_TZ=True,
        SOUTH_TESTS_MIGRATE=True,
    )


if SWAPPED:
    settings.INSTALLED_APPS.append('allaccess.tests.custom')
    settings.AUTH_USER_MODEL = 'custom.MyUser'

from django import VERSION
from django.test.utils import get_runner
from south.management.commands import patch_for_test_db_setup


def runtests():
    patch_for_test_db_setup()
    apps = sys.argv[1:] or ['allaccess', ]
    if SWAPPED and VERSION[0] == 1 and VERSION[1] < 6:
        apps.append('custom')
    TestRunner = get_runner(settings)
    test_runner = TestRunner(verbosity=1, interactive=True, failfast=False)
    failures = test_runner.run_tests(apps)
    sys.exit(failures)


if __name__ == '__main__':
    runtests()
<commit_msg>Adjusting runtests to handle Django 1.7 changes as well as having south as an optional depedency.<commit_after>#!/usr/bin/env python
import os
import sys

import django
from django.conf import settings

try:
    import social_auth
except ImportError:
    social_auth = None

try:
    import south
except ImportError:
    south = None

SWAPPED = os.environ.get('SWAPPED', False)

INSTALLED_APPS = [
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.admin',
    'allaccess',
]

if south is not None:
    INSTALLED_APPS.append('south')

if social_auth is not None:
    INSTALLED_APPS.append('social_auth')

if not settings.configured:
    settings.configure(
        DATABASES={
            'default': {
                'ENGINE': 'django.db.backends.sqlite3',
                'NAME': ':memory:',
            }
        },
        INSTALLED_APPS=INSTALLED_APPS,
        AUTHENTICATION_BACKENDS=(
            'allaccess.backends.AuthorizedServiceBackend',
        ),
        SITE_ID=1,
        SECRET_KEY='<KEY>',
        ROOT_URLCONF='allaccess.tests.urls',
        LOGIN_URL='/login/',
        LOGIN_REDIRECT_URL='/',
        USE_TZ=True,
        SOUTH_TESTS_MIGRATE=True,
    )


if SWAPPED:
    settings.INSTALLED_APPS.append('allaccess.tests.custom')
    settings.AUTH_USER_MODEL = 'custom.MyUser'

from django import VERSION
from django.test.utils import get_runner
try:
    from south.management.commands import patch_for_test_db_setup
except ImportError:
    patch_for_test_db_setup = lambda: None


def runtests():
    if hasattr(django, 'setup'):
        django.setup()
    patch_for_test_db_setup()
    apps = sys.argv[1:] or ['allaccess', ]
    if SWAPPED and VERSION[0] == 1 and VERSION[1] < 6:
        apps.append('custom')
    TestRunner = get_runner(settings)
    test_runner = TestRunner(verbosity=1, interactive=True, failfast=False)
    failures = test_runner.run_tests(apps)
    sys.exit(failures)


if __name__ == '__main__':
    runtests()

{'fraction_non_alphanumeric': 0.114307731826355, 'fraction_numerical': 0.0046236835345491905, 'mean_word_length': 2.9979466119096507, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '703806', 'n_tokens_mistral': 1327, 'n_tokens_neox': 1290, 'n_words': 243}