Esempio n. 1
0
def _run_suite(suite, testclass=None):
    if junit_xml_dir:
        from junit_xml import JUnitXMLTestRunner
        runner = JUnitXMLTestRunner(junit_xml_dir)
    elif verbose:
        runner = unittest.TextTestRunner(sys.stdout, verbosity=2)
    else:
        runner = BasicTestRunner()

    result = runner.run(suite)
    if not result.wasSuccessful():
        if len(result.errors) == 1 and not result.failures:
            err = result.errors[0][1]
        elif len(result.failures) == 1 and not result.errors:
            err = result.failures[0][1]
        else:
            err = "multiple errors occurred"
            if not verbose:
                err += "; run in verbose mode for details"
        raise TestFailed(err)
Esempio n. 2
0
def _run_suite(suite, testclass=None):
    if junit_xml_dir:
        from junit_xml import JUnitXMLTestRunner
        runner = JUnitXMLTestRunner(junit_xml_dir)
    elif verbose:
        runner = unittest.TextTestRunner(sys.stdout, verbosity=2)
    else:
        runner = BasicTestRunner()

    result = runner.run(suite)
    if not result.wasSuccessful():
        if len(result.errors) == 1 and not result.failures:
            err = result.errors[0][1]
        elif len(result.failures) == 1 and not result.errors:
            err = result.failures[0][1]
        else:
            err = "multiple errors occurred"
            if not verbose:
                err += "; run in verbose mode for details"
        raise TestFailed(err)
Esempio n. 3
0
def _run_suite(suite, testclass=None):
    """Run tests from a unittest.TestSuite-derived class."""
    if junit_xml_dir:
        from junit_xml import JUnitXMLTestRunner
        runner = JUnitXMLTestRunner(junit_xml_dir)
    elif verbose:
        runner = unittest.TextTestRunner(sys.stdout, verbosity=2)
    else:
        runner = BasicTestRunner()

    result = runner.run(suite)
    if not result.wasSuccessful():
        if len(result.errors) == 1 and not result.failures:
            err = result.errors[0][1]
        elif len(result.failures) == 1 and not result.errors:
            err = result.failures[0][1]
        else:
            if testclass is None:
                msg = "errors occurred; run in verbose mode for details"
            else:
                msg = "errors occurred in %s.%s" \
                      % (testclass.__module__, testclass.__name__)
            raise TestFailed(msg)
        raise TestFailed(err)
Esempio n. 4
0
def _run_suite(suite, testclass=None):
    """Run tests from a unittest.TestSuite-derived class."""
    if junit_xml_dir:
        from junit_xml import JUnitXMLTestRunner
        runner = JUnitXMLTestRunner(junit_xml_dir)
    elif verbose:
        runner = unittest.TextTestRunner(sys.stdout, verbosity=2)
    else:
        runner = BasicTestRunner()

    result = runner.run(suite)
    if not result.wasSuccessful():
        if len(result.errors) == 1 and not result.failures:
            err = result.errors[0][1]
        elif len(result.failures) == 1 and not result.errors:
            err = result.failures[0][1]
        else:
            if testclass is None:
                msg = "errors occurred; run in verbose mode for details"
            else:
                msg = "errors occurred in %s.%s" \
                      % (testclass.__module__, testclass.__name__)
            raise TestFailed(msg)
        raise TestFailed(err)