forked from jazzband/django-tinymce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runtests.py
49 lines (44 loc) · 1.46 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
import argparse
import os
import sys
# Force this to happen before loading django
try:
os.environ["DJANGO_SETTINGS_MODULE"] = "testtinymce.settings"
test_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, test_dir)
except ImportError:
pass
else:
import django
from django.conf import settings
from django.test.utils import get_runner
def runtests(modules=["tinymce"], verbosity=1, failfast=False):
django.setup()
TestRunner = get_runner(settings)
test_runner = TestRunner(interactive=True, verbosity=verbosity, failfast=failfast)
failures = test_runner.run_tests(modules)
sys.exit(bool(failures))
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Run the django-tinymce test suite.")
parser.add_argument(
"modules",
nargs="*",
metavar="module",
help='Optional path(s) to test modules; e.g. "tinymce" or '
'"tinymce.tests.test_widgets".',
)
parser.add_argument(
"-v",
"--verbosity",
default=1,
type=int,
choices=[0, 1, 2, 3],
help="Verbosity level; 0=minimal output, 1=normal output, 2=all output",
)
parser.add_argument(
"--failfast",
action="store_true",
help="Stop running the test suite after first failed test.",
)
options = parser.parse_args()
runtests(modules=options.modules, verbosity=options.verbosity, failfast=options.failfast)