pylib/mercurial-support/silenttestrunner.py
author Gregory Szorc <gps@mozilla.com>
Mon, 29 Sep 2014 14:27:56 -0700
changeset 359535 6fe00a59b64d5706f262fcca94d097836e965b03
permissions -rw-r--r--
testing: add silentestrunner.py from Mercurial Mercurial has a unittest wrapper that allows executing of unittest-based Python tests. We import it so we can run the existing pushlog tests with minimal effort.

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)