Esempio n. 1
0
    def run(self):
        sys.dont_write_bytecode = True
        os.environ['DJANGO_SETTINGS_MODULE'] = 'test_suite.settings_for_tests'
        setup_django()
        # import django
        # try:
        #     django.setup()
        # except AttributeError:
        #     pass

        try:
            from django.utils.unittest import TextTestRunner, defaultTestLoader
        except ImportError:
            print("Please install Django => 1.4.2 to run the test suite")
            exit(-1)

        from test_suite import (
            test_forms, test_models, test_templatetags, test_widgets)
        suite = defaultTestLoader.loadTestsFromModule(test_forms)
        suite.addTests(defaultTestLoader.loadTestsFromModule(test_models))
        suite.addTests(
            defaultTestLoader.loadTestsFromModule(test_templatetags))
        suite.addTests(defaultTestLoader.loadTestsFromModule(test_widgets))
        runner = TextTestRunner()
        result = runner.run(suite)
        if result.wasSuccessful() is not True:
            raise SystemExit(int(bool(result.errors or result.failures)))
Esempio n. 2
0
 def run_suite(self, suite, **kwargs):
     signals.before_suite_run.send(sender=self)
     result = TextTestRunner(buffer=True, resultclass=XMLTestResult).run(suite)
     if self.with_reports:
         result.dump_xml(self.output_dir)
     signals.after_suite_run.send(sender=self)
     return result
Esempio n. 3
0
def main():

    print('*'*80)
    print('django '+'.'.join(map(str,django.VERSION[0:3])))
    print('*'*80)

    project_dir = os.path.dirname(__file__)
    cov_files = []
    for d in DIRS:
        for (path, dirs, files) in os.walk(os.path.join(project_dir,d)):
            if os.path.basename(path) == 'tests' or os.path.basename(path) == "migrations":
                continue
            cov_files.extend([os.path.join(path, file) for file in files if file.endswith('.py') and file != "tests.py"])
    cov = coverage()
    cov.erase()
    cov.start()

    try:
        django.setup()
    except AttributeError:
        pass

    TestRunner = get_runner(settings)
    test_runner = TestRunner(verbosity=2, interactive=False, failfast=False)

    # code from djanog.tests.runner, which does this:
    test_runner.setup_test_environment()
    suite = test_runner.build_suite(DIRS, None)
    old_config = test_runner.setup_databases()
    result = TextTestRunner(buffer=True, resultclass=XMLTestResult, verbosity=test_runner.verbosity).run(suite)
    test_runner.teardown_databases(old_config)
    test_runner.teardown_test_environment()
    failures = test_runner.suite_result(suite, result)

    cov.stop()
    # cov.report(cov_files)
    cov.xml_report(cov_files)
    cov.html_report(cov_files)

    result.dump_xml('.')
    sys.exit(failures)
Esempio n. 4
0
    def run(self):
        sys.dont_write_bytecode = True
        os.environ['DJANGO_SETTINGS_MODULE'] = 'test_suite.settings_for_tests'
        setup_django()

        try:
            from django.utils.unittest import TextTestRunner, defaultTestLoader
        except ImportError:
            from unittest import TextTestRunner, defaultTestLoader

        from test_suite import (
            test_forms, test_models, test_templatetags, test_widgets)
        suite = defaultTestLoader.loadTestsFromModule(test_forms)
        suite.addTests(defaultTestLoader.loadTestsFromModule(test_models))
        suite.addTests(
            defaultTestLoader.loadTestsFromModule(test_templatetags))
        suite.addTests(defaultTestLoader.loadTestsFromModule(test_widgets))
        runner = TextTestRunner()
        result = runner.run(suite)
        if result.wasSuccessful() is not True:
            raise SystemExit(int(bool(result.errors or result.failures)))
Esempio n. 5
0
	def run_suite(self, suite, **kwargs):
		""" Hook in from parent class so we can use our own result class """
		ttr = TextTestRunner(verbosity=self.verbosity, failfast=self.failfast, resultclass=MHLResult)
		return ttr.run(suite)
Esempio n. 6
0
 def __init__(self, stream=sys.stderr, descriptions=1, verbosity=1,
              config=None):
     if config is None:
         config = Config()
     self.config = config
     TextTestRunner.__init__(self, stream, descriptions, verbosity, buffer=True)