1 | import os |
||
2 | import sys |
||
3 | import django |
||
4 | from django.conf import settings |
||
5 | from django.test.utils import get_runner |
||
6 | |||
7 | DJANGO_VERSION = float('.'.join([str(i) for i in django.VERSION[0:2]])) |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
![]() Comprehensibility
Best Practice
introduced
by
|
|||
8 | DIR_NAME = os.path.dirname(__file__) |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
9 | localpath = lambda p: os.path.join(os.path.dirname(__file__), p) |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
10 | |||
11 | settings.configure( |
||
12 | DEBUG=True, |
||
13 | DATABASES={ |
||
14 | 'default': { |
||
15 | 'ENGINE': 'django.db.backends.sqlite3', |
||
16 | } |
||
17 | }, |
||
18 | INSTALLED_APPS=( |
||
19 | 'django.contrib.auth', |
||
20 | 'django.contrib.contenttypes', |
||
21 | 'django.contrib.sessions', |
||
22 | 'django.contrib.admin', |
||
23 | 'django.contrib.staticfiles', |
||
24 | 'crudbuilder', |
||
25 | 'django_tables2', |
||
26 | |||
27 | 'crudbuilder.tests', |
||
28 | ), |
||
29 | ROOT_URLCONF='crudbuilder.tests.urls', |
||
30 | LOGIN_REQUIRED_FOR_CRUD=True, |
||
31 | |||
32 | MIDDLEWARE_CLASSES=( |
||
33 | 'django.contrib.sessions.middleware.SessionMiddleware', |
||
34 | 'django.middleware.common.CommonMiddleware', |
||
35 | 'django.middleware.csrf.CsrfViewMiddleware', |
||
36 | 'django.contrib.auth.middleware.AuthenticationMiddleware', |
||
37 | 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', |
||
38 | 'django.contrib.messages.middleware.MessageMiddleware', |
||
39 | 'django.middleware.clickjacking.XFrameOptionsMiddleware'), |
||
40 | |||
41 | TEMPLATE_LOADERS=( |
||
42 | 'django.template.loaders.filesystem.Loader', |
||
43 | 'django.template.loaders.app_directories.Loader', |
||
44 | 'django.template.loaders.eggs.Loader' |
||
45 | ), |
||
46 | |||
47 | STATIC_URL='/static/', |
||
48 | |||
49 | TEMPLATES=[ |
||
50 | { |
||
51 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', |
||
52 | 'DIRS': [ |
||
53 | localpath('templates'), |
||
54 | ], |
||
55 | 'APP_DIRS': True, |
||
56 | 'OPTIONS': { |
||
57 | 'context_processors': [ |
||
58 | 'django.template.context_processors.debug', |
||
59 | 'django.template.context_processors.request', |
||
60 | 'django.contrib.auth.context_processors.auth', |
||
61 | 'django.contrib.messages.context_processors.messages', |
||
62 | ], |
||
63 | }, |
||
64 | }, |
||
65 | ] |
||
66 | |||
67 | ) |
||
68 | |||
69 | django.setup() |
||
70 | |||
71 | if DJANGO_VERSION == 1.7: |
||
72 | settings.TEMPLATE_CONTEXT_PROCESSORS = ( |
||
73 | "django.contrib.auth.context_processors.auth", |
||
74 | "django.core.context_processors.debug", |
||
75 | "django.core.context_processors.i18n", |
||
76 | "django.core.context_processors.media", |
||
77 | "django.core.context_processors.static", |
||
78 | "django.core.context_processors.request", |
||
79 | "django.contrib.messages.context_processors.messages") |
||
80 | |||
81 | settings.TEMPLATE_DIRS = ( |
||
82 | localpath('templates') |
||
83 | ) |
||
84 | |||
85 | TestRunner = get_runner(settings) |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
86 | test_runner = TestRunner() |
||
87 | failures = test_runner.run_tests(['crudbuilder', ]) |
||
88 | |||
89 | if failures: |
||
90 | sys.exit(bool(failures)) |
||
91 |