tests/silenttestrunner.py
author Matt Harbison <matt_harbison@yahoo.com>
Mon, 20 Sep 2021 11:05:30 -0400
changeset 48013 376d08ae904f
parent 43076 2372284d9457
child 48875 6000f5b25c9b
permissions -rw-r--r--
util: eliminate the possibility of returning None from `versiontuple()` This fixes the following error flagged by pytype: File "/mnt/c/Users/Matt/hg/mercurial/extensions.py", line 228, in load: unsupported operand types for > [unsupported-operands] Primitive types 'Optional[tuple]' and 'curver: Optional[tuple]' are not comparable. Differential Revision: https://phab.mercurial-scm.org/D11473

from __future__ import absolute_import, print_function
import os
import sys
import unittest


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)


if os.environ.get('SILENT_BE_NOISY'):
    main = unittest.main