gas/runtests.py

64 lines
2.1 KiB
Python
Executable File

#!/usr/bin/env python
import sys
import django
from django.conf import settings
from django.core.management import call_command
def runtests():
if not settings.configured:
# Configure test environment
settings.configure(
SECRET_KEY="test-secret",
DATABASES={
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:'
}
},
INSTALLED_APPS=(
'django.contrib.sessions',
'django.contrib.contenttypes',
'django.contrib.auth',
'gas',
),
ROOT_URLCONF='gas.tests.urls',
MIDDLEWARE_CLASSES=(),
MESSAGE_STORAGE='django.contrib.messages.storage.cookie.CookieStorage',
TEMPLATES=[
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
],
MIDDLEWARE=[
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
],
)
django.setup()
call_command(
'migrate', interactive=False, verbosity=0)
failures = call_command(
'test', 'gas', interactive=False, failfast=False, verbosity=2)
sys.exit(bool(failures))
if __name__ == '__main__':
runtests()