forked from django-background-tasks/django-background-tasks
-
Notifications
You must be signed in to change notification settings - Fork 16
/
runtests.py
executable file
·32 lines (24 loc) · 876 Bytes
/
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import django
from django.conf import settings
from django.test.utils import get_runner
from argparse import ArgumentParser
def main(argv):
parser = ArgumentParser()
parser.add_argument(
"--async", "-a", action="store_true", default=False, dest="run_async",
help="process background tasks in multiple threads")
args = parser.parse_args(argv)
os.environ['DJANGO_SETTINGS_MODULE'] = 'background_task.tests.test_settings'
if args.run_async:
os.environ['DJANGO_SETTINGS_MODULE'] = 'background_task.tests.test_settings_async'
django.setup()
TestRunner = get_runner(settings)
test_runner = TestRunner()
failures = test_runner.run_tests(["background_task.tests"])
sys.exit(bool(failures))
if __name__ == "__main__":
main(argv=sys.argv[1:])