forked from GamesDoneQuick/donation-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathruntests.py
More file actions
61 lines (57 loc) · 1.97 KB
/
runtests.py
File metadata and controls
61 lines (57 loc) · 1.97 KB
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
#!/usr/bin/env python
import os
import sys
import logging
import json
from argparse import ArgumentParser
from subprocess import check_call
import django
from django.conf import settings
from django.test.utils import get_runner
from celery import Celery
# needs additional dependencies
# pip install -r tests/requirements.txt
# must be run from the tracker root folder, for now
if __name__ == '__main__':
os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.test_settings'
django.setup()
app = Celery()
app.config_from_object(
{'task_always_eager': True,}
)
logging.getLogger('post_office').disabled = True
parser = ArgumentParser()
# stolen from run test command
parser.add_argument(
'args',
metavar='test_label',
nargs='*',
help='Module paths to test; can be modulename, modulename.TestCase or modulename.TestCase.test_method',
)
parser.add_argument(
'--noinput',
'--no-input',
action='store_false',
dest='interactive',
default=True,
help='Tells Django to NOT prompt the user for input of any kind.',
)
parser.add_argument(
'--failfast',
action='store_true',
dest='failfast',
default=False,
help='Tells Django to stop running the test suite after first failed test.',
)
# TODO: the fetches for the ui endpoints blow up if the manifest doesn't exist so we have to build the webpack bundles first
try:
json.load(open('tracker/ui-tracker.manifest.json'))['files']['tracker']
except (IOError, KeyError):
check_call(['yarn', '--frozen-lockfile', '--production'])
check_call(['yarn', 'build'])
TestRunner = get_runner(settings, 'xmlrunner.extra.djangotestrunner.XMLTestRunner')
TestRunner.add_arguments(parser)
parsed = parser.parse_args(sys.argv[1:])
test_runner = TestRunner(**parsed.__dict__)
failures = test_runner.run_tests(parsed.args or ['tests'])
sys.exit(bool(failures))