~ubuntuone-hackers/django-secure/trunk

« back to all changes in this revision

Viewing changes to runtests.py

  • Committer: Carl Meyer
  • Date: 2014-10-23 18:00:11 UTC
  • Revision ID: git-v1:2605d682acc99dbf9fb9c69dea60671638d4323c
Update tox.ini; hide tests from old Django test runners.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/env python
2
2
 
3
 
import os, sys
 
3
import sys
4
4
 
5
5
from django.conf import settings
6
 
 
7
 
 
8
 
if not settings.configured:
9
 
    settings.configure(
10
 
        INSTALLED_APPS=["djangosecure"],
11
 
        DATABASES={"default": {"ENGINE": "django.db.backends.sqlite3"}})
12
 
 
13
 
 
14
 
def runtests(*test_args):
15
 
    if not test_args:
16
 
        test_args = ["djangosecure"]
17
 
 
18
 
    parent = os.path.dirname(os.path.abspath(__file__))
19
 
    sys.path.insert(0, parent)
 
6
import django
 
7
 
 
8
 
 
9
DEFAULT_SETTINGS = dict(
 
10
    INSTALLED_APPS=['djangosecure', 'djangosecure.tests'],
 
11
    DATABASES={"default": {"ENGINE": "django.db.backends.sqlite3"}},
 
12
    SILENCED_SYSTEM_CHECKS=["1_7.W001"],
 
13
)
 
14
 
 
15
 
 
16
def runtests():
 
17
    if not settings.configured:
 
18
        settings.configure(**DEFAULT_SETTINGS)
 
19
 
 
20
    # Compatibility with Django 1.7's stricter initialization
 
21
    if hasattr(django, 'setup'):
 
22
        django.setup()
 
23
 
 
24
    print(sys.path)
20
25
 
21
26
    try:
 
27
        from django.test.runner import DiscoverRunner
 
28
        runner_class = DiscoverRunner
 
29
        test_args = ['djangosecure.tests']
 
30
    except ImportError:
22
31
        from django.test.simple import DjangoTestSuiteRunner
23
 
        def run_tests(test_args, verbosity, interactive):
24
 
            runner = DjangoTestSuiteRunner(
25
 
                verbosity=verbosity, interactive=interactive, failfast=False)
26
 
            return runner.run_tests(test_args)
27
 
    except ImportError:
28
 
        # for Django versions that don't have DjangoTestSuiteRunner
29
 
        from django.test.simple import run_tests
30
 
    failures = run_tests(test_args, verbosity=1, interactive=True)
 
32
        runner_class = DjangoTestSuiteRunner
 
33
        test_args = ['tests']
 
34
 
 
35
    failures = runner_class(
 
36
        verbosity=1, interactive=True, failfast=False).run_tests(test_args)
31
37
    sys.exit(failures)
32
38
 
33
39