def pytest_configure():
    from django.conf import settings

    settings.configure(
        DEBUG_PROPAGATE_EXCEPTIONS=True,
        DATABASES={'default': {'ENGINE': 'django.db.backends.sqlite3',
                               'NAME': ':memory:'}},
        SITE_ID=1,
        SECRET_KEY='not very secret in tests',
        USE_I18N=True,
        USE_L10N=True,
        STATIC_URL='/static/',
        ROOT_URLCONF='tests.urls',
        TEMPLATES=[
            {
                'BACKEND': 'django.template.backends.django.DjangoTemplates',
                'DIRS': [],
                'APP_DIRS': True,
                'OPTIONS': {
                    'context_processors': [
                        'django.template.context_processors.debug',
                        'django.template.context_processors.request',
                        'django.contrib.auth.context_processors.auth',
                        'django.contrib.messages.context_processors.messages',
                    ],
                },
            },
        ],
        MIDDLEWARE_CLASSES=(
            'django.middleware.common.CommonMiddleware',
            'django.contrib.sessions.middleware.SessionMiddleware',
            'django.middleware.csrf.CsrfViewMiddleware',
            'django.contrib.auth.middleware.AuthenticationMiddleware',
            'django.contrib.messages.middleware.MessageMiddleware',
        ),
        INSTALLED_APPS=(
            'django.contrib.auth',
            'django.contrib.contenttypes',
            'django.contrib.sessions',
            'django.contrib.sites',
            'django.contrib.messages',
            'django.contrib.staticfiles',

            'rest_framework_simplejwt.token_blacklist',

            'tests',

            'auth_backend.role',
            'auth_backend.permission',
            'auth_backend.user',
        ),
        PASSWORD_HASHERS=(
            'django.contrib.auth.hashers.SHA1PasswordHasher',
            'django.contrib.auth.hashers.PBKDF2PasswordHasher',
            'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
            'django.contrib.auth.hashers.BCryptPasswordHasher',
            'django.contrib.auth.hashers.MD5PasswordHasher',
            'django.contrib.auth.hashers.CryptPasswordHasher',
        ),
        AUTH_USER_MODEL='tests.TestUser',
        AUTHENTICATION_BACKENDS=['django.contrib.auth.backends.AllowAllUsersModelBackend'],  # noqa: E501
        AUTH_PASSWORD_VALIDATORS=[
            {
                'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',  # noqa: E501
            },
            {
                'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',  # noqa: E501
                'OPTIONS': {
                    'min_length': 10,
                }
            },
            {
                'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',  # noqa: E501
            },
            {
                'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',  # noqa: E501
            },
        ],
        REST_FRAMEWORK={
            'DEFAULT_PERMISSION_CLASSES': (
                'rest_framework.permissions.IsAuthenticated',
                'auth_backend.permission.permissions.HasRolePermission',
            ),
        },
        PROJECT_NAME="Company name",
        FROM_EMAIL="support@example.com",
    )

    try:
        import django
        django.setup()
    except AttributeError:
        pass
