| 1 |
import os |
| 2 |
import sys |
| 3 |
import unittest |
| 4 |
|
| 5 |
|
| 6 |
def main(modulename): |
| 7 |
'''run the tests found in module, printing nothing when all tests pass''' |
| 8 |
module = sys.modules[modulename] |
| 9 |
suite = unittest.defaultTestLoader.loadTestsFromModule(module) |
| 10 |
results = unittest.TestResult() |
| 11 |
suite.run(results) |
| 12 |
if results.errors or results.failures: |
| 13 |
for tc, exc in results.errors: |
| 14 |
print('ERROR:', tc) |
| 15 |
print() |
| 16 |
sys.stdout.write(exc) |
| 17 |
for tc, exc in results.failures: |
| 18 |
print('FAIL:', tc) |
| 19 |
print() |
| 20 |
sys.stdout.write(exc) |
| 21 |
sys.exit(1) |
| 22 |
|
| 23 |
|
| 24 |
if os.environ.get('SILENT_BE_NOISY'): |
| 25 |
main = unittest.main |