forked from AndrewIngram/django-extra-views
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runtests.py
executable file
·75 lines (62 loc) · 2.25 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
#!/usr/bin/env python
import sys
import logging
from optparse import OptionParser
from django.conf import settings
logging.disable(logging.CRITICAL)
def configure(nose_args=None):
if not settings.configured:
settings.configure(
DATABASES={
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:',
}},
INSTALLED_APPS=[
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.auth',
'extra_views',
'extra_views.tests',
],
ROOT_URLCONF='',
DEBUG=False,
USE_TZ=False,
NOSE_ARGS=nose_args
)
def runtests(*test_args):
from django_nose import NoseTestSuiteRunner
runner = NoseTestSuiteRunner()
if not test_args:
test_args = ['extra_views.tests']
num_failures = runner.run_tests(test_args)
if num_failures:
sys.exit(num_failures)
if __name__ == '__main__':
parser = OptionParser()
parser.add_option('--with-coverage', dest='coverage', default=False,
action='store_true')
parser.add_option('--with-xunit', dest='xunit', default=False,
action='store_true')
parser.add_option('--with-spec', dest='with_spec', default=False,
action='store_true')
parser.add_option('--pdb', dest='pdb', default=False,
action='store_true')
options, args = parser.parse_args()
# If no args, then use 'progressive' plugin to keep the screen real estate
# used down to a minimum. Otherwise, use the spec plugin
nose_args = ['-s', '-x']
if options.with_spec:
nose_args.append('--spec-color')
else:
nose_args.append('--with-progressive')
if options.pdb:
nose_args.append('--pdb')
if options.coverage:
# Nose automatically uses any options passed to runtests.py, which is
# why the coverage trigger uses '--with-coverage' and why we don't need
# to explicitly include it here.
nose_args.extend([
'--cover-package=extra_views', '--cover-html', '--cover-html-dir=htmlcov'])
configure(nose_args)
runtests()