tests/silenttestrunner.py
author Razvan Cojocaru <razvan.cojocaru93@gmail.com>
Sun, 16 Mar 2014 17:31:31 +0200
changeset 22276 b13b99d39a46
parent 18665 2cbfb8c497ee
child 23308 dadcd40b62d8
permissions -rw-r--r--
config: highlight parse error caused by leading spaces (issue3214) Added "unexpected leading whitespace" message to parse error when .hgrc has a line that starts with whitespace. Helps new users unfamiliar with syntax of rc file.

import unittest, sys

def main(modulename):
    '''run the tests found in module, printing nothing when all tests pass'''
    module = sys.modules[modulename]
    suite = unittest.defaultTestLoader.loadTestsFromModule(module)
    results = unittest.TestResult()
    suite.run(results)
    if results.errors or results.failures:
        for tc, exc in results.errors:
            print 'ERROR:', tc
            print
            sys.stdout.write(exc)
        for tc, exc in results.failures:
            print 'FAIL:', tc
            print
            sys.stdout.write(exc)
        sys.exit(1)