forked from italomaia/model_mommy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runtests.py
40 lines (28 loc) · 913 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
33
34
35
36
37
38
39
40
#!/usr/bin/env python
import os
import sys
parent = os.path.abspath(os.path.dirname(__file__))
sys.path.insert(0, parent)
os.environ['DJANGO_SETTINGS_MODULE'] = 'test_settings'
def runtests():
verbose_level = 1
args = sys.argv[1:]
if '-v' in args:
index = args.index('-v')
_ = args.pop(index)
verbose_level = int(args.pop(index))
if args:
test_labels = ["model_mommy.%s" % arg for arg in args]
else:
test_labels = ['model_mommy']
try:
from django.test.simple import run_tests
result = run_tests(test_labels, verbose_level, True)
sys.exit(result)
except ImportError:
from django.test.simple import DjangoTestSuiteRunner
test_suite = DjangoTestSuiteRunner(verbose_level, True)
result = test_suite.run_tests(test_labels)
sys.exit(result)
if __name__ == '__main__':
runtests()