44c6f699930f09319615bfa4fd5ffffb794bb672
[django-pagination.git] / linaro_django_pagination / tests / runner.py
1 #!/usr/bin/env python
2 import django
3 import doctest
4 import sys
5
6 from django.conf import settings
7
8
9 def runtests():
10     if not settings.configured:
11         # Configure test environment
12         settings.configure(
13             SECRET_KEY='fake-key',
14             INSTALLED_APPS=(
15                 'linaro_django_pagination',
16             ),
17         )
18
19     try:
20         django.setup()
21     except AttributeError:  # for Django 1.6 compatible
22         pass
23
24     from django.test.utils import get_runner
25
26     TestRunner = get_runner(settings)
27     test_runner = TestRunner()
28     failures = test_runner.run_tests(
29         ["linaro_django_pagination.tests"],
30         extra_tests=[doctest.DocTestSuite('linaro_django_pagination.tests.test_main')]
31     )
32     sys.exit(bool(failures))
33
34
35 if __name__ == '__main__':
36     runtests()