forked from GamesDoneQuick/donation-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathruntests.py
66 lines (62 loc) · 2.06 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
#!/usr/bin/env python
import os
import subprocess
import sys
import logging
from argparse import ArgumentParser
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.',
)
try:
subprocess.check_call(
['yarn', 'build'],
env={**os.environ, 'NODE_ENV': 'development', 'NO_HMR': '1'},
)
except subprocess.SubprocessError:
# maybe failed because the modules aren't installed
subprocess.check_call(['yarn', '--frozen-lockfile', '--production'])
subprocess.check_call(
['yarn', 'build'],
env={**os.environ, 'NODE_ENV': 'development', 'NO_HMR': '1'},
)
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))