testing: add silentestrunner.py from Mercurial
authorGregory Szorc <gps@mozilla.com>
Mon, 29 Sep 2014 14:27:56 -0700
changeset 359535 6fe00a59b64d5706f262fcca94d097836e965b03
parent 359534 e3d700020d5c21dabf6464b4c5db62700f792ce3
child 359536 6970204fcccd4a87f0474cddb2f11e81425b5b71
push id16998
push userrwood@mozilla.com
push dateMon, 02 May 2016 19:42:03 +0000
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.
pylib/mercurial-support/silenttestrunner.py
new file mode 100644
--- /dev/null
+++ b/pylib/mercurial-support/silenttestrunner.py
@@ -0,0 +1,19 @@
+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)
+