import sys

from colour_runner.django_runner import ColourRunnerMixin
from django.conf import settings


settings.configure(
    INSTALLED_APPS=(
        # Put contenttypes before auth to work around test issue.
        # See: https://code.djangoproject.com/ticket/10827#comment:12
        'django.contrib.contenttypes',
        'django.contrib.auth',
        'django.contrib.sessions',
        'django.contrib.admin',

        'incuna_auth',
    ),
    PASSWORD_HASHERS = ('django.contrib.auth.hashers.MD5PasswordHasher',),
    AUTH_USER_MODEL='tests.User',
    ROOT_URLCONF='incuna_auth.urls',
    REST_FRAMEWORK={
        'DEFAULT_PERMISSION_CLASSES': ('rest_framework.permissions.IsAuthenticated',),
        'DEFAULT_RENDERER_CLASSES': ('rest_framework.renderers.JSONRenderer',),
    },
    LOGIN_REQUIRED_SEND_MESSAGE=False,
    LOGIN_EXEMPT_URLS = (
        '^exempt-url/$',
        '^exempt-and-protected-url/$',
    ),
    LOGIN_PROTECTED_URLS = (
        '^exempt-and-protected-url/$',
        '^protected-url/$',
    ),

)


from django.test.runner import DiscoverRunner


class Runner(ColourRunnerMixin, DiscoverRunner):
    pass

test_runner = Runner(verbosity=1)
failures = test_runner.run_tests(['tests'])
if failures:
    sys.exit(1)

@@ -118,16 +118,50 @@
 figure(%0A
+    # Core environmental settings%0A
     INST
@@ -817,16 +817,52 @@
 ,%0A    %7D,
+%0A%0A    # LoginRequiredMiddleware data
 %0A    LOG
@@ -1094,16 +1094,190 @@
     ),%0A%0A
+    # BasicAuthenticationMiddleware data%0A    BASIC_WWW_AUTHENTICATION_USERNAME = 'user',%0A    BASIC_WWW_AUTHENTICATION_PASSWORD = 'pass',%0A    BASIC_WWW_AUTHENTICATION = True,%0A
 )%0A%0A%0Afrom

Add environmental settings for basic authentication.