forked from simodalla/mezzanine_page_auth
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runtests.py
52 lines (41 loc) · 1.68 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import os
import sys
os.environ['DJANGO_SETTINGS_MODULE'] = 'project_template.settings'
project_template_dir = os.path.join(
os.path.dirname(os.path.abspath(__file__)), 'project_template')
sys.path.insert(0, project_template_dir)
from django.test.utils import get_runner
from django.conf import settings
def runtests(tests=('mezzanine_page_auth',)):
"""
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 ``mezzanine_page_auth``
runtests(['mezzanine_page_auth'])
# only run testcase class ``UnauthorizedListPagesPageAuthGroupTest``
# from app ``mezzanine_page_auth``
runtests(['mezzanine_page_auth.UnauthorizedListPagesPageAuthGroupTest'])
# run all tests from application ``mezzanine_page_auth`` and the test
# named ``test_register`` on the
# ``mezzanine_page_auth.UnauthorizedListPagesPageAuthGroupTest``
# testcase.
runtests(['mezzanine_page_auth.UnauthorizedListPagesPageAuthGroupTest.
test_unauthorized_list_pages_with_user_with_one_group''])
"""
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()