Mercurial > hg
annotate tests/silenttestrunner.py @ 19888:1b2f9d36953e
generaldelta: fix test
author | Wojciech Lopata <lopek@fb.com> |
---|---|
date | Mon, 30 Sep 2013 18:27:42 -0700 |
parents | 2cbfb8c497ee |
children | dadcd40b62d8 |
rev | line source |
---|---|
18665
2cbfb8c497ee
tests: add a test runner utility that prints nothing when all tests pass
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
1 import unittest, sys |
2cbfb8c497ee
tests: add a test runner utility that prints nothing when all tests pass
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
2 |
2cbfb8c497ee
tests: add a test runner utility that prints nothing when all tests pass
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
3 def main(modulename): |
2cbfb8c497ee
tests: add a test runner utility that prints nothing when all tests pass
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
4 '''run the tests found in module, printing nothing when all tests pass''' |
2cbfb8c497ee
tests: add a test runner utility that prints nothing when all tests pass
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
5 module = sys.modules[modulename] |
2cbfb8c497ee
tests: add a test runner utility that prints nothing when all tests pass
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
6 suite = unittest.defaultTestLoader.loadTestsFromModule(module) |
2cbfb8c497ee
tests: add a test runner utility that prints nothing when all tests pass
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
7 results = unittest.TestResult() |
2cbfb8c497ee
tests: add a test runner utility that prints nothing when all tests pass
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
8 suite.run(results) |
2cbfb8c497ee
tests: add a test runner utility that prints nothing when all tests pass
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
9 if results.errors or results.failures: |
2cbfb8c497ee
tests: add a test runner utility that prints nothing when all tests pass
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
10 for tc, exc in results.errors: |
2cbfb8c497ee
tests: add a test runner utility that prints nothing when all tests pass
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
11 print 'ERROR:', tc |
2cbfb8c497ee
tests: add a test runner utility that prints nothing when all tests pass
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
12 print |
2cbfb8c497ee
tests: add a test runner utility that prints nothing when all tests pass
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
13 sys.stdout.write(exc) |
2cbfb8c497ee
tests: add a test runner utility that prints nothing when all tests pass
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
14 for tc, exc in results.failures: |
2cbfb8c497ee
tests: add a test runner utility that prints nothing when all tests pass
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
15 print 'FAIL:', tc |
2cbfb8c497ee
tests: add a test runner utility that prints nothing when all tests pass
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
16 print |
2cbfb8c497ee
tests: add a test runner utility that prints nothing when all tests pass
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
17 sys.stdout.write(exc) |
2cbfb8c497ee
tests: add a test runner utility that prints nothing when all tests pass
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
18 sys.exit(1) |