This repository has been archived by the owner on Jul 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runtests.py
executable file
·115 lines (101 loc) · 4.3 KB
/
runtests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
from __future__ import unicode_literals
import os
import sys
import django
from django.conf import settings
def configure():
if not settings.configured:
# Helper function to extract absolute path
location = lambda x: os.path.join(
os.path.dirname(os.path.realpath(__file__)),
'cmsplugin_googleplus', 'tests', 'example_project', x)
test_settings = {
'LANGUAGE_CODE': 'en',
'LANGUAGES': (('en', 'English'),),
'DATABASES': {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:',
},
},
'INSTALLED_APPS': [
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
'cms',
'treebeard',
'menus',
'sekizai',
'djangocms_admin_style',
'django.contrib.admin',
'cmsplugin_googleplus'],
'ROOT_URLCONF': 'cmsplugin_googleplus.tests.example_project.urls',
'MIDDLEWARE_CLASSES': (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'cms.middleware.user.CurrentUserMiddleware',
'cms.middleware.page.CurrentPageMiddleware',
'cms.middleware.toolbar.ToolbarMiddleware',
'cms.middleware.language.LanguageCookieMiddleware',
),
'STATIC_URL': '/static/',
'ADMINS': ('admin@example.com',),
'DEBUG': False,
'SITE_ID': 1,
'APPEND_SLASH': True,
'CMS_TEMPLATES': (('nav_playground.html', 'Test Template'),),
'TEMPLATES': [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [location('templates'), ],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'django.template.context_processors.i18n',
'django.template.context_processors.request',
'django.template.context_processors.media',
'django.template.context_processors.static',
'cms.context_processors.cms_settings',
'sekizai.context_processors.sekizai',
],
'debug': False
},
},
]}
settings.configure(**test_settings)
def run_tests(*test_args):
if not test_args:
test_args = ['cmsplugin_googleplus']
# see:
# https://docs.djangoproject.com/en/dev/releases/1.7/#standalone-scripts
django.setup()
from django.core.management import call_command
call_command("makemigrations", "cmsplugin_googleplus", database='default')
call_command("migrate", database='default')
from django_nose import NoseTestSuiteRunner
failures = NoseTestSuiteRunner().run_tests(test_args)
if failures: # pragma: no cover
sys.exit(failures)
if __name__ == '__main__':
args = sys.argv[1:]
if args:
# Some args specified. Check to see if any nose options have been
# specified. If they have, then don't set any
has_options = any([x.startswith('--') for x in args])
if not has_options:
args.extend(['-s', '-x', '--with-specplugin'])
else:
# Remove options as nose will pick these up from sys.argv
args = [arg for arg in args if not arg.startswith('-')]
configure()
run_tests(*args)