source: main/branches/3D/openPLM/plmapp/tests/runner.py @ 662

Revision 662, 1.2 KB checked in by pcosquer, 9 years ago (diff)

3D branch: merge changes from trunk (rev [661])

Line 
1# from: http://djangosnippets.org/snippets/2211/ by cronosa
2import os
3import logging
4from django.conf import settings
5EXCLUDED_APPS = getattr(settings, 'TEST_EXCLUDE', [])
6from django.test.simple import DjangoTestSuiteRunner
7from django_xml_test_runner.xmltestrunner import XMLTestSuiteRunner
8
9if os.environ.get("TEST_OUTPUT", "stdin") == "xml":
10    TestSuiteRunner = XMLTestSuiteRunner
11else:
12    TestSuiteRunner= DjangoTestSuiteRunner
13
14class OpenPLMTestSuiteRunner(TestSuiteRunner):
15    def __init__(self, *args, **kwargs):
16        from django.conf import settings
17        settings.TESTING = True
18        south_log = logging.getLogger("south")
19        south_log.setLevel(logging.WARNING)
20        super(OpenPLMTestSuiteRunner, self).__init__(*args, **kwargs)
21   
22    def build_suite(self, *args, **kwargs):
23        suite = super(OpenPLMTestSuiteRunner, self).build_suite(*args, **kwargs)
24        if not args[0] and not getattr(settings, 'RUN_ALL_TESTS', False):
25            tests = []
26            for case in suite:
27                pkg = case.__class__.__module__.split('.')[0]
28                if pkg == "openPLM":
29                    tests.append(case)
30            suite._tests = tests
31        return suite
Note: See TracBrowser for help on using the repository browser.