forked from jazzband/django-admin2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runtests.py
executable file
·45 lines (34 loc) · 1.3 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
#!/usr/bin/env python
import os
import sys
os.environ['DJANGO_SETTINGS_MODULE'] = 'example.settings'
exampleproject_dir = os.path.join(os.path.dirname(__file__), 'example')
sys.path.insert(0, exampleproject_dir)
from django.test.utils import get_runner
from django.conf import settings
def runtests(tests=('blog', 'djadmin2',)):
'''
Takes a list as first argument, enumerating the apps and specific testcases
that should be executed. The syntax is the same as for what you would pass
to the ``django-admin.py test`` command.
Examples::
# run the default test suite
runtests()
# only run the tests from application ``blog``
runtests(['blog'])
# only run testcase class ``Admin2Test`` from app ``djadmin2``
runtests(['djadmin2.Admin2Test'])
# run all tests from application ``blog`` and the test named
# ``test_register`` on the ``djadmin2.Admin2Test`` testcase.
runtests(['djadmin2.Admin2Test.test_register', 'blog'])
'''
TestRunner = get_runner(settings)
test_runner = TestRunner(verbosity=1, interactive=True)
failures = test_runner.run_tests(tests)
sys.exit(bool(failures))
if __name__ == '__main__':
if len(sys.argv) > 1:
tests = sys.argv[1:]
runtests(tests)
else:
runtests()